refactor: Rely purely on module.exports

This commit is contained in:
dkamyshov
2019-11-21 17:14:08 +01:00
committed by Mariusz Nowak
parent 403a7e9190
commit 5065cb86ec
3 changed files with 8 additions and 6 deletions
+2 -2
View File
@@ -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
View File
@@ -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":
+1 -1
View File
@@ -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))();
};