mirror of
https://github.com/hanzoai/es5-ext.git
synced 2026-09-24 16:58:43 +00:00
refactor: Rely purely on module.exports
This commit is contained in:
+2
-2
@@ -5,7 +5,7 @@ var assign = require("../object/assign")
|
||||
, isValue = require("../object/is-value")
|
||||
, captureStackTrace = Error.captureStackTrace;
|
||||
|
||||
exports = 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)) {
|
||||
@@ -15,6 +15,6 @@ exports = module.exports = function (message/*, code, ext*/) {
|
||||
}
|
||||
if (isValue(ext)) assign(err, ext);
|
||||
if (isValue(code)) err.code = code;
|
||||
if (captureStackTrace) captureStackTrace(err, exports);
|
||||
if (captureStackTrace) captureStackTrace(err, module.exports);
|
||||
return err;
|
||||
};
|
||||
|
||||
+5
-3
@@ -8,18 +8,20 @@ var toArray = require("./to-array")
|
||||
var isArray = Array.isArray
|
||||
, stringify = JSON.stringify
|
||||
, objHasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var keyValueToString = function (value, key) { return stringify(key) + ":" + exports(value); };
|
||||
var keyValueToString = function (value, key) {
|
||||
return stringify(key) + ":" + module.exports(value);
|
||||
};
|
||||
|
||||
var sparseMap = function (arr) {
|
||||
var i, length = arr.length, result = new Array(length);
|
||||
for (i = 0; i < length; ++i) {
|
||||
if (!objHasOwnProperty.call(arr, i)) continue;
|
||||
result[i] = exports(arr[i]);
|
||||
result[i] = module.exports(arr[i]);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = exports = function (obj) {
|
||||
module.exports = function (obj) {
|
||||
if (!isValue(obj)) return String(obj);
|
||||
switch (typeof obj) {
|
||||
case "string":
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
var value = require("./valid-value");
|
||||
|
||||
module.exports = exports = function (code) {
|
||||
module.exports = function (code) {
|
||||
// eslint-disable-next-line no-new-func
|
||||
return new Function("return " + value(code))();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user