@lskjs/utils
Advanced tools
Comparing version 2.12.3 to 2.13.0
{ | ||
"name": "@lskjs/utils", | ||
"version": "2.12.3", | ||
"version": "2.13.0", | ||
"description": "LSK.js – utils – helpers and functions", | ||
@@ -41,3 +41,3 @@ "keywords": [], | ||
}, | ||
"gitHead": "04e53e23ad2d447c1fa7ff8e42722735a7e4addc" | ||
"gitHead": "914dad0e7db49d00f8df85df3894f1dc4465c002" | ||
} |
@@ -9,3 +9,3 @@ "use strict"; | ||
exports.params = params; | ||
exports["default"] = exports.parse = exports.toDate = exports.toJson = exports.toInt = exports.toNumber = exports.toBoolean = exports.notNan = void 0; | ||
exports["default"] = exports.parse = exports.toArray = exports.toDate = exports.toJson = exports.toInt = exports.toNumber = exports.toBoolean = exports.notNan = void 0; | ||
@@ -26,2 +26,3 @@ var _forEach = _interopRequireDefault(require("lodash/forEach")); | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
var notNan = function notNan(a) { | ||
@@ -36,3 +37,3 @@ var def = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
var def = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
return Boolean((0, _tryParamParse["default"])(a, def)); | ||
return a === null ? def : Boolean((0, _tryParamParse["default"])(a, def)); | ||
}; | ||
@@ -70,2 +71,15 @@ | ||
var toArray = function toArray(a) { | ||
var def = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
if (a === null) return def; | ||
if (Array.isArray(a)) return a; | ||
if (typeof a !== 'string') return [toJson(a)]; | ||
if (a === '') return []; | ||
return a.split(',').map(function (b) { | ||
return toJson(b); | ||
}); | ||
}; | ||
exports.toArray = toArray; | ||
var parse = function parse(a, type, def) { | ||
@@ -77,2 +91,3 @@ if (type === 'boolean' || type === 'bool') return toBoolean(a, def); | ||
if (type === 'date') return toDate(a, def); | ||
if (type === 'array') return toArray(a, def); | ||
return a; | ||
@@ -79,0 +94,0 @@ }; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
359357
3631