mirror of
https://github.com/hanzoai/es5-ext.git
synced 2026-09-24 16:58:43 +00:00
style: Prettify
This commit is contained in:
+2
-1
@@ -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)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -10,11 +10,9 @@ 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
|
||||
) {
|
||||
return pattern.replace(
|
||||
/%([a-zA-Z]+)|\\([\u0000-\uffff])/g,
|
||||
function (match, token, escapeChar) {
|
||||
var t, result;
|
||||
if (escapeChar) return escapeChar;
|
||||
t = token;
|
||||
@@ -22,6 +20,7 @@ module.exports = function (fmap) {
|
||||
if (!result) return match;
|
||||
if (isCallable(result)) result = call.call(result, context);
|
||||
return result + token.slice(t.length);
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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");
|
||||
};
|
||||
|
||||
@@ -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"); });
|
||||
};
|
||||
|
||||
@@ -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
|
||||
) {
|
||||
t.call(
|
||||
new Promise(function (resolve, reject) { reject(error); }),
|
||||
function (passedError, value) {
|
||||
a(passedError, error);
|
||||
a(value, undefined);
|
||||
d();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user