Fix: cacheFirstCall -> memoize
This commit is contained in:
parent
8531d20c55
commit
b27b6676fa
|
@ -1,4 +1,4 @@
|
|||
/* global cacheFirstCall editorWorker stylelint csslint showCodeMirrorPopup loadScript messageBox */
|
||||
/* global memoize editorWorker stylelint csslint showCodeMirrorPopup loadScript messageBox */
|
||||
'use strict';
|
||||
|
||||
(() => {
|
||||
|
@ -26,7 +26,7 @@
|
|||
return;
|
||||
}
|
||||
const storageName = linter === 'styleint' ? 'editorStylelintConfig' : 'editorCSSLintConfig';
|
||||
const getRules = cacheFirstCall(linter === 'stylelint' ?
|
||||
const getRules = memoize(linter === 'stylelint' ?
|
||||
editorWorker.getStylelintRules : editorWorker.getCsslintRules);
|
||||
const linterTitle = linter === 'stylelint' ? 'Stylelint' : 'CSSLint';
|
||||
const defaultConfig = stringifyConfig(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global linter editorWorker cacheFirstCall */
|
||||
/* global linter editorWorker memoize */
|
||||
'use strict';
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
|
@ -49,7 +49,7 @@ var csslint = (() => {
|
|||
};
|
||||
let config;
|
||||
|
||||
const prepareConfig = cacheFirstCall(() => {
|
||||
const prepareConfig = memoize(() => {
|
||||
chrome.storage.onChanged.addListener((changes, area) => {
|
||||
if (area !== 'sync' || !changes.hasOwnProperty('editorCSSLintConfig')) {
|
||||
return;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* global showHelp editorWorker cacheFirstCall */
|
||||
/* global showHelp editorWorker memoize */
|
||||
'use strict';
|
||||
|
||||
function createLinterHelpDialog(getIssues) {
|
||||
let csslintRules;
|
||||
const prepareCsslintRules = cacheFirstCall(() =>
|
||||
const prepareCsslintRules = memoize(() =>
|
||||
editorWorker.getCsslintRules()
|
||||
.then(rules => {
|
||||
csslintRules = rules;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global linter editorWorker cacheFirstCall */
|
||||
/* global linter editorWorker memoize */
|
||||
'use strict';
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
|
@ -174,7 +174,7 @@ var stylelint = (() => {
|
|||
};
|
||||
let config;
|
||||
|
||||
const prepareConfig = cacheFirstCall(() => {
|
||||
const prepareConfig = memoize(() => {
|
||||
chrome.storage.onChanged.addListener((changes, area) => {
|
||||
if (area !== 'sync' || !changes.hasOwnProperty('editorStylelintConfig')) {
|
||||
return;
|
||||
|
|
|
@ -123,7 +123,7 @@ function clipString(str, limit = 100) {
|
|||
}
|
||||
|
||||
// this is a decorator. Cache the first call
|
||||
function cacheFirstCall(fn) {
|
||||
function memoize(fn) {
|
||||
let cached = false;
|
||||
let result;
|
||||
return (...args) => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user