$ cnpm install @putout/plugin-declare
????Putout plugin adds ability to declare variable that was not defined before, including:
maybeArray, maybeFn, maybeEmptyArray;not,id, returns;difference;freshImport, freshImportDefault;fixtures: readFixture;Object;String + addQuotes;npm i putout @putout/plugin-declare -D
Add .putout.json with:
{
"plugins": {
"declare": "on"
}
}
Use options:
dismiss for variables you don't want to declare;declarations to declare variables;{
"rules": {
"declare": ["on", {
"declarations": {
"hello": "import {hello} from 'world'"
},
"dismiss": [
"assert",
"entries",
"parse",
"stringify",
"defineProperty",
"noop",
"join",
"keys",
"values",
"stopAll",
"once",
"putout"
]
}]
}
}
assignconst hello = 'world';
const object = {};
assign(object, {
hello,
});
const hello = 'world';
const object = {};
const {assign} = Object;
assign(object, {
hello,
});
keysconst hello = 'world';
const object = {};
const allKeys = keys(object);
const hello = 'world';
const object = {};
const {keys} = Object;
const allKeys = keys(object);
valuesconst object = {};
const allValues = values(object);
const {values} = Object;
const object = {};
const allValues = values(object);
noopnoop();
const noop = () => {};
noop();
const isFn = (a) => typeof a === 'function';
if (isFn(fn))
fn();
const isFn = (a) => typeof a === 'function';
if (isFn(fn))
fn();
const a = maybeArray(b);
const {isArray} = Array;
const maybeArray = (a) => isArray(a) ? a : [a];
const a = maybeArray(b);
entriesentries([1, 2, 3]);
const {entries} = Object;
entries([1, 2, 3]);
fromEntriesfromEntries(['hello', 'world']);
const {fromEntries} = Object;
fromEntries(['hello', 'world']);
fromCharCodeconst encoded = new TextEncoder().encode(str);
fromCharCode(...encoded);
const {fromCharCode} = String;
const encoded = new TextEncoder().encode(str);
fromCharCode(...encoded);
MIT
Copyright 2013 - present © cnpmjs.org | Home |