style: Prettify

This commit is contained in:
Mariusz Nowak
2022-03-07 13:27:20 +01:00
parent 9f0ef0007a
commit 59f9b074fd
51 changed files with 78 additions and 70 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ isSpreadable = function (value) {
};
// eslint-disable-next-line no-unused-vars
module.exports = function (item/*, …items*/) {
module.exports = function (item /*, …items*/) {
var result;
if (!this || !isArray(this) || isPlainArray(this)) {
return concat.apply(this, arguments);
+1 -1
View File
@@ -2,6 +2,6 @@
var indexOf = require("./e-index-of");
module.exports = function (searchElement/*, position*/) {
module.exports = function (searchElement /*, position*/) {
return indexOf.call(this, searchElement, arguments[1]) > -1;
};
+1 -1
View File
@@ -9,7 +9,7 @@ var toInteger = require("../../../number/to-integer")
, max = Math.max
, min = Math.min;
module.exports = function (target, start/*, end*/) {
module.exports = function (target, start /*, end*/) {
var arr = validValue(this)
, end = arguments[2]
, length = toPosInt(arr.length)
+1 -1
View File
@@ -8,7 +8,7 @@ var numberIsNaN = require("../../number/is-nan")
, abs = Math.abs
, floor = Math.floor;
module.exports = function (searchElement/*, fromIndex*/) {
module.exports = function (searchElement /*, fromIndex*/) {
var i, length, fromIndex, val;
if (!numberIsNaN(searchElement)) return indexOf.apply(this, arguments);
+1 -1
View File
@@ -8,7 +8,7 @@ var numberIsNaN = require("../../number/is-nan")
, abs = Math.abs
, floor = Math.floor;
module.exports = function (searchElement/*, fromIndex*/) {
module.exports = function (searchElement /*, fromIndex*/) {
var i, fromIndex, val;
if (!numberIsNaN(searchElement)) {
// Jslint: ignore
+1 -1
View File
@@ -8,7 +8,7 @@ var toInteger = require("../../../number/to-integer")
, max = Math.max
, min = Math.min;
module.exports = function (value/*, start, end*/) {
module.exports = function (value /*, start, end*/) {
var arr = validValue(this)
, start = arguments[1]
, end = arguments[2]
+1 -1
View File
@@ -7,7 +7,7 @@ var isPlainArray = require("../../is-plain-array")
, forEach = Array.prototype.forEach
, call = Function.prototype.call;
module.exports = function (callbackFn/*, thisArg*/) {
module.exports = function (callbackFn /*, thisArg*/) {
var result, thisArg, i;
if (!this || !isArray(this) || isPlainArray(this)) {
return filter.apply(this, arguments);
+1 -1
View File
@@ -5,7 +5,7 @@ var callable = require("../../../object/valid-callable")
, some = Array.prototype.some
, apply = Function.prototype.apply;
module.exports = function (predicate/*, thisArg*/) {
module.exports = function (predicate /*, thisArg*/) {
var k, self;
self = Object(ensureValue(this));
callable(predicate);
+1 -1
View File
@@ -3,7 +3,7 @@
var findIndex = require("../find-index/shim");
// eslint-disable-next-line no-unused-vars
module.exports = function (predicate/*, thisArg*/) {
module.exports = function (predicate /*, thisArg*/) {
var index = findIndex.apply(this, arguments);
return index === -1 ? undefined : this[index];
};
+1 -1
View File
@@ -6,7 +6,7 @@ var toPosInt = require("../../number/to-pos-integer")
, objHasOwnProperty = Object.prototype.hasOwnProperty
, call = Function.prototype.call;
module.exports = function (cb/*, thisArg*/) {
module.exports = function (cb /*, thisArg*/) {
var i, self, thisArg;
self = Object(value(this));
+1 -1
View File
@@ -8,7 +8,7 @@ var callable = require("../../object/valid-callable")
, forEach = Array.prototype.forEach
, apply = Function.prototype.apply;
module.exports = function (cb/*, thisArg*/) {
module.exports = function (cb /*, thisArg*/) {
var result;
value(this);
+1 -1
View File
@@ -2,7 +2,7 @@
var indexOf = require("./e-index-of");
module.exports = function (value/*, fromIndex*/) {
module.exports = function (value /*, fromIndex*/) {
var result = [], i, fromIndex = arguments[1];
while ((i = indexOf.call(this, value, fromIndex)) !== -1) {
result.push(i);
+1 -1
View File
@@ -7,7 +7,7 @@ var isPlainArray = require("../../is-plain-array")
, forEach = Array.prototype.forEach
, call = Function.prototype.call;
module.exports = function (callbackFn/*, thisArg*/) {
module.exports = function (callbackFn /*, thisArg*/) {
var result, thisArg;
if (!this || !isArray(this) || isPlainArray(this)) {
return map.apply(this, arguments);
+1 -1
View File
@@ -5,7 +5,7 @@ var indexOf = require("./e-index-of")
, splice = Array.prototype.splice;
// eslint-disable-next-line no-unused-vars
module.exports = function (itemToRemove/*, …item*/) {
module.exports = function (itemToRemove /*, …item*/) {
forEach.call(
arguments,
function (item) {
+1 -1
View File
@@ -6,7 +6,7 @@ var toPosInt = require("../../number/to-pos-integer")
, objHasOwnProperty = Object.prototype.hasOwnProperty
, call = Function.prototype.call;
module.exports = function (cb/*, thisArg*/) {
module.exports = function (cb /*, thisArg*/) {
var i, self, thisArg;
self = Object(value(this));
callable(cb);
+1 -1
View File
@@ -6,7 +6,7 @@ var isPlainArray = require("../../is-plain-array")
, forEach = Array.prototype.forEach;
// eslint-disable-next-line no-unused-vars
module.exports = function (start, deleteCount/*, …items*/) {
module.exports = function (start, deleteCount /*, …items*/) {
var arr = splice.apply(this, arguments), result;
if (!this || !isArray(this) || isPlainArray(this)) return arr;
result = new this.constructor(arr.length);
+1 -1
View File
@@ -14,7 +14,7 @@ var iteratorSymbol = require("es6-symbol").iterator
, defineProperty = Object.defineProperty;
// eslint-disable-next-line complexity, max-lines-per-function
module.exports = function (arrayLike/*, mapFn, thisArg*/) {
module.exports = function (arrayLike /*, mapFn, thisArg*/) {
var mapFn = arguments[1]
, thisArg = arguments[2]
, Context
+1 -1
View File
@@ -4,7 +4,7 @@ var toPosInt = require("../number/to-pos-integer")
, value = require("../object/valid-value")
, slice = Array.prototype.slice;
module.exports = function (length/*, …fill*/) {
module.exports = function (length /*, …fill*/) {
var arr, currentLength;
length = toPosInt(value(length));
if (length === 0) return [];
+1 -1
View File
@@ -5,7 +5,7 @@ var assign = require("../object/assign")
, isValue = require("../object/is-value")
, captureStackTrace = Error.captureStackTrace;
module.exports = function (message/*, code, ext*/) {
module.exports = function (message /*, code, ext*/) {
var err = new Error(message), code = arguments[1], ext = arguments[2];
if (!isValue(ext)) {
if (isObject(code)) {
+1 -1
View File
@@ -8,7 +8,7 @@ var apply = Function.prototype.apply
, call = Function.prototype.call
, callFn = function (arg, fn) { return call.call(fn, this, arg); };
module.exports = function (fnIgnored/*, …fnn*/) {
module.exports = function (fnIgnored /*, …fnn*/) {
var fns, first;
var args = aFrom(arguments);
fns = isValue(this) ? [this].concat(args) : args;
+1 -1
View File
@@ -5,7 +5,7 @@ var isCallable = require("../object/is-callable")
, slice = Array.prototype.slice
, apply = Function.prototype.apply;
module.exports = function (name/*, …args*/) {
module.exports = function (name /*, …args*/) {
var args = slice.call(arguments, 1), isFn = isCallable(name);
return function (obj) {
value(obj);
+1 -1
View File
@@ -5,7 +5,7 @@ var forOf = require("es6-iterator/for-of")
, iterable = require("./validate")
, forEach = Array.prototype.forEach;
module.exports = function (target, cb/*, thisArg*/) {
module.exports = function (target, cb /*, thisArg*/) {
if (isIterable(iterable(target))) forOf(target, cb, arguments[2]);
else forEach.call(target, cb, arguments[2]);
};
+1 -1
View File
@@ -6,7 +6,7 @@ var compact = require("../array/#/compact")
, isArray = Array.isArray
, stringify = JSON.stringify;
module.exports = function self(value/*, replacer, space*/) {
module.exports = function self(value /*, replacer, space*/) {
var replacer = arguments[1], space = arguments[2];
try {
return stringify(value, replacer, space);
+1 -1
View File
@@ -10,7 +10,7 @@ var isValue = require("../object/is-value")
var split = String.prototype.split;
module.exports = function (type) {
return function (value/*, exp*/) {
return function (value /*, exp*/) {
value = Number(value);
var exp = arguments[1];
if (isValue(exp)) exp = ensureInteger(exp);
+1 -1
View File
@@ -10,7 +10,7 @@ var some = Array.prototype.some
, add = function (sum, number) { return sum + number * number; };
// eslint-disable-next-line no-unused-vars
module.exports = function (val1, val2/*, …valn*/) {
module.exports = function (val1, val2 /*, …valn*/) {
var result, numbers;
if (!arguments.length) return 0;
some.call(arguments, function (val) {
+1 -1
View File
@@ -4,7 +4,7 @@ var pad = require("../../string/#/pad")
, toPosInt = require("../to-pos-integer")
, toFixed = Number.prototype.toFixed;
module.exports = function (length/*, precision*/) {
module.exports = function (length /*, precision*/) {
var precision;
length = toPosInt(length);
precision = toPosInt(arguments[1]);
+2 -1
View File
@@ -5,6 +5,7 @@ var objToString = Object.prototype.toString, id = objToString.call(1);
module.exports = function (value) {
return (
typeof value === "number" ||
(value instanceof Number || (typeof value === "object" && objToString.call(value) === id))
value instanceof Number ||
(typeof value === "object" && objToString.call(value) === id)
);
};
+1 -1
View File
@@ -12,7 +12,7 @@ var callable = require("./valid-callable")
, objPropertyIsEnumerable = Object.prototype.propertyIsEnumerable;
module.exports = function (method, defVal) {
return function (obj, cb/*, thisArg, compareFn*/) {
return function (obj, cb /*, thisArg, compareFn*/) {
var list, thisArg = arguments[2], compareFn = arguments[3];
obj = Object(value(obj));
callable(cb);
+1 -1
View File
@@ -27,7 +27,7 @@ var deepAssign = function (target, source) {
return source;
};
module.exports = function (target/*, ...objects*/) {
module.exports = function (target /*, ...objects*/) {
return uniq
.call([ensureValue(target)].concat(slice.call(arguments, 1).map(ensureValue)))
.reduce(deepAssign);
+1 -1
View File
@@ -4,7 +4,7 @@ var keys = require("../keys")
, value = require("../valid-value")
, max = Math.max;
module.exports = function (dest, src/*, …srcn*/) {
module.exports = function (dest, src /*, …srcn*/) {
var error, i, length = max(arguments.length, 2), assign;
dest = Object(value(dest));
assign = function (key) {
+1 -1
View File
@@ -4,7 +4,7 @@ var aFrom = require("../array/from")
, assign = require("./assign")
, value = require("./valid-value");
module.exports = function (obj/*, propertyNames, options*/) {
module.exports = function (obj /*, propertyNames, options*/) {
var copy = Object(value(obj)), propertyNames = arguments[1], options = Object(arguments[2]);
if (copy !== obj && !propertyNames) return copy;
var result = {};
+1 -1
View File
@@ -4,7 +4,7 @@ var callable = require("./valid-callable")
, forEach = require("./for-each")
, call = Function.prototype.call;
module.exports = function (obj, cb/*, thisArg*/) {
module.exports = function (obj, cb /*, thisArg*/) {
var result = {}, thisArg = arguments[2];
callable(cb);
forEach(obj, function (value, key, targetObj, index) {
+1 -1
View File
@@ -4,7 +4,7 @@ var findKey = require("./find-key")
, isValue = require("./is-value");
// eslint-disable-next-line no-unused-vars
module.exports = function (obj, cb/*, thisArg, compareFn*/) {
module.exports = function (obj, cb /*, thisArg, compareFn*/) {
var key = findKey.apply(this, arguments);
return isValue(key) ? obj[key] : key;
};
+1 -1
View File
@@ -4,7 +4,7 @@ var callable = require("./valid-callable")
, forEach = require("./for-each")
, call = Function.prototype.call;
module.exports = function (obj, cb/*, thisArg*/) {
module.exports = function (obj, cb /*, thisArg*/) {
var result = {}, thisArg = arguments[2];
callable(cb);
forEach(
+1 -1
View File
@@ -4,7 +4,7 @@ var callable = require("./valid-callable")
, forEach = require("./for-each")
, call = Function.prototype.call;
module.exports = function (obj, cb/*, thisArg*/) {
module.exports = function (obj, cb /*, thisArg*/) {
var result = {}, thisArg = arguments[2];
callable(cb);
forEach(obj, function (value, key, targetObj, index) {
+1 -1
View File
@@ -10,7 +10,7 @@ var process = function (src, obj) {
};
// eslint-disable-next-line no-unused-vars
module.exports = function (opts1/*, …options*/) {
module.exports = function (opts1 /*, …options*/) {
var result = create(null);
forEach.call(arguments, function (options) {
if (!isValue(options)) return;
+1 -1
View File
@@ -3,7 +3,7 @@
var forEach = Array.prototype.forEach, create = Object.create;
// eslint-disable-next-line no-unused-vars
module.exports = function (arg/*, …args*/) {
module.exports = function (arg /*, …args*/) {
var set = create(null);
forEach.call(arguments, function (name) { set[name] = true; });
return set;
+1 -1
View File
@@ -3,7 +3,7 @@
var value = require("./valid-value")
, isValue = require("./is-value");
module.exports = function (obj/*, …names*/) {
module.exports = function (obj /*, …names*/) {
var length, current = 1;
value(obj);
length = arguments.length - 1;
+1 -1
View File
@@ -6,7 +6,7 @@ var callable = require("./valid-callable")
, call = Function.prototype.call
, defaultCb = function (value, key) { return [key, value]; };
module.exports = function (obj/*, cb, thisArg, compareFn*/) {
module.exports = function (obj /*, cb, thisArg, compareFn*/) {
var a = [], cb = arguments[1], thisArg = arguments[2];
cb = isValue(cb) ? callable(cb) : defaultCb;
+1 -1
View File
@@ -5,7 +5,7 @@ var isValue = require("./object/is-value");
var slice = Array.prototype.slice;
// eslint-disable-next-line no-unused-vars
module.exports = function (value, propertyName1/*, …propertyNamen*/) {
module.exports = function (value, propertyName1 /*, …propertyNamen*/) {
var propertyNames = slice.call(arguments, 1), index = 0, length = propertyNames.length;
while (isValue(value) && index < length) value = value[propertyNames[index++]];
return index === length ? value : undefined;
+1 -1
View File
@@ -2,6 +2,6 @@
var indexOf = String.prototype.indexOf;
module.exports = function (searchString/*, position*/) {
module.exports = function (searchString /*, position*/) {
return indexOf.call(this, searchString, arguments[1]) > -1;
};
+1 -1
View File
@@ -6,7 +6,7 @@ var toInteger = require("../../../number/to-integer")
, min = Math.min
, max = Math.max;
module.exports = function (searchString/*, endPosition*/) {
module.exports = function (searchString /*, endPosition*/) {
var self, start, endPos;
self = String(value(this));
searchString = String(searchString);
+1 -1
View File
@@ -5,7 +5,7 @@ var isValue = require("../../object/is-value")
, replace = String.prototype.replace
, re = /(\r\n|[\n\r\u2028\u2029])([\u0000-\u0009\u000b-\uffff]+)/g;
module.exports = function (indent/*, count*/) {
module.exports = function (indent /*, count*/) {
var count = arguments[1];
indent = repeat.call(String(indent), isValue(count) ? count : 1);
return indent + replace.call(this, re, "$1" + indent + "$2");
+1 -1
View File
@@ -6,7 +6,7 @@ var toInteger = require("../../number/to-integer")
, abs = Math.abs
, max = Math.max;
module.exports = function (fill/*, length*/) {
module.exports = function (fill /*, length*/) {
var self = String(value(this)), sLength = self.length, length = arguments[1];
length = isNaN(length) ? 1 : toInteger(length);
+1 -1
View File
@@ -5,7 +5,7 @@ var value = require("../../../object/valid-value")
, max = Math.max
, min = Math.min;
module.exports = function (searchString/*, position*/) {
module.exports = function (searchString /*, position*/) {
var start, self = String(value(this));
start = min(max(toInteger(arguments[1]), 0), self.length);
return self.indexOf(searchString, start) === start;
+12 -13
View File
@@ -10,18 +10,17 @@ module.exports = function (fmap) {
var context = this;
value(context);
pattern = String(pattern);
return pattern.replace(/%([a-zA-Z]+)|\\([\u0000-\uffff])/g, function (
match,
token,
escapeChar
) {
var t, result;
if (escapeChar) return escapeChar;
t = token;
while (t && !(result = fmap[t])) t = t.slice(0, -1);
if (!result) return match;
if (isCallable(result)) result = call.call(result, context);
return result + token.slice(t.length);
});
return pattern.replace(
/%([a-zA-Z]+)|\\([\u0000-\uffff])/g,
function (match, token, escapeChar) {
var t, result;
if (escapeChar) return escapeChar;
t = token;
while (t && !(result = fmap[t])) t = t.slice(0, -1);
if (!result) return match;
if (isCallable(result)) result = call.call(result, context);
return result + token.slice(t.length);
}
);
};
};
+1 -1
View File
@@ -9,7 +9,7 @@
var floor = Math.floor, fromCharCode = String.fromCharCode;
// eslint-disable-next-line no-unused-vars
module.exports = function (codePoint1/*, …codePoints*/) {
module.exports = function (codePoint1 /*, …codePoints*/) {
var chars = [], length = arguments.length, i, codePoint, result = "";
for (i = 0; i < length; ++i) {
codePoint = Number(arguments[i]);
+1 -1
View File
@@ -4,7 +4,7 @@ var toPosInt = require("../../number/to-pos-integer")
, validValue = require("../../object/valid-value")
, reduce = Array.prototype.reduce;
module.exports = function (callSite/*, …substitutions*/) {
module.exports = function (callSite /*, …substitutions*/) {
var args, rawValue = Object(validValue(Object(validValue(callSite)).raw));
if (!toPosInt(rawValue.length)) return "";
args = arguments;
+7 -1
View File
@@ -2,7 +2,13 @@
module.exports = function (t, a) {
a.deep(t({ foo: "bar" }), [["foo", "bar"]], "Object");
a.deep(t("raz"), [["0", "r"], ["1", "a"], ["2", "z"]], "Primitive");
a.deep(
t("raz"),
[
["0", "r"], ["1", "a"], ["2", "z"]
],
"Primitive"
);
a.throws(function () { t(); }, TypeError, "Undefined");
a.throws(function () { t(null); }, TypeError, "Undefined");
};
+3 -1
View File
@@ -14,5 +14,7 @@ module.exports = function (t, a) {
);
a.deep(o2, [2, 4, 6]);
t(o).sort().forEach(function (item) { a.deep(item, [item[0], o[item[0]]], "Default"); });
t(o)
.sort()
.forEach(function (item) { a.deep(item, [item[0], o[item[0]]], "Default"); });
};
+8 -8
View File
@@ -12,14 +12,14 @@ module.exports = function (t, a) {
},
Failure: function (d) {
var error = new Error("Rejection");
t.call(new Promise(function (resolve, reject) { reject(error); }), function (
passedError,
value
) {
a(passedError, error);
a(value, undefined);
d();
});
t.call(
new Promise(function (resolve, reject) { reject(error); }),
function (passedError, value) {
a(passedError, error);
a(value, undefined);
d();
}
);
}
};
};