Comparing version 0.1.15 to 0.1.16
@@ -5,41 +5,28 @@ 'use strict'; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
const oc = Object.prototype.toString; | ||
/** | ||
* | ||
* @param {*} node | ||
* @param {*} o | ||
* @return {*} | ||
*/ | ||
function clone(node) { | ||
if (!node || typeof node != 'object') return node; | ||
switch (true) { | ||
case Array.isArray(node): | ||
return cloneArray(node); | ||
function clone(o) { | ||
if (!o || typeof o !== 'object') return o; | ||
const t = oc.call(o).slice(8, 11); | ||
case node instanceof Date: | ||
return new Date(+node); | ||
// new Date(node.valueOf()) //new Date(+node); | ||
switch (t) { | ||
case 'Arr': | ||
return cloneArray(o); | ||
case node instanceof Map: | ||
return cloneMap(node); | ||
case 'Obj': | ||
return cloneObject(o); | ||
case node instanceof Set: | ||
return new Set(cloneArray([...node])); | ||
case 'Map': | ||
return cloneMap(o); | ||
case node instanceof Object: | ||
return cloneObject(node); | ||
case 'Dat': | ||
return new Date(+o); | ||
case 'Set': | ||
return new Set(cloneArray([...o])); | ||
} | ||
@@ -51,3 +38,3 @@ | ||
* | ||
* @param {Map<*, *>} node | ||
* @param {Map<*, *>} o | ||
* @return {Map<*, *>} | ||
@@ -57,8 +44,8 @@ */ | ||
function cloneMap(node) { | ||
return new Map([...node.entries()].map(([k, v]) => [k, clone(v)])); | ||
function cloneMap(o) { | ||
return new Map([...o.entries()].map(([k, v]) => [k, clone(v)])); | ||
} | ||
/** | ||
* | ||
* @param {*[]} node | ||
* @param {*[]} o | ||
* @return {*[]} | ||
@@ -68,4 +55,4 @@ */ | ||
function cloneArray(node) { | ||
return node.map(clone); | ||
function cloneArray(o) { | ||
return o.map(clone); | ||
} | ||
@@ -75,3 +62,3 @@ /** | ||
* Unable to clone circular and nested object. | ||
* @param {{}} node | ||
* @param {{}} o | ||
* @return {{}} | ||
@@ -81,6 +68,6 @@ */ | ||
function cloneObject(node) { | ||
function cloneObject(o) { | ||
const x = {}; | ||
for (let [k, v] of Object.entries(node)) x[k] = clone(v); | ||
for (let [k, v] of Object.entries(o)) x[k] = clone(v); | ||
@@ -90,2 +77,6 @@ return x; | ||
/** | ||
* Static class containing methods create 1d-array. | ||
*/ | ||
class Vec { | ||
@@ -98,3 +89,3 @@ /** | ||
*/ | ||
static ini(size, ject = i => 0) { | ||
static ini(size, ject) { | ||
if (typeof ject === 'function') { | ||
@@ -123,2 +114,6 @@ if (size <= 128) { | ||
static clone(arr) { | ||
return cloneArray(arr); | ||
} | ||
static indexes(arr) { | ||
@@ -250,12 +245,3 @@ return arr.map((_, i) => i); | ||
} // Array.prototype.zip = function (another, zipper) { | ||
// let ar = []; | ||
// for (let i = 0; i < this.length; i++) { | ||
// ar[i] = zipper(this[i], another[i]) | ||
// } | ||
// return ar | ||
// }; | ||
_defineProperty(Vec, "clone", cloneArray); | ||
// Create an object type VehoError | ||
@@ -278,2 +264,5 @@ class VehoError extends Error { | ||
class Jso { | ||
static clone(o) { | ||
return cloneObject(o); | ||
} | ||
/** | ||
@@ -284,2 +273,4 @@ * | ||
*/ | ||
static toEntries(jso) { | ||
@@ -399,4 +390,2 @@ return Object.entries(jso); | ||
_defineProperty(Jso, "clone", cloneObject); | ||
class JsonTable { | ||
@@ -563,2 +552,17 @@ /** | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
class Dic { | ||
@@ -666,1 +670,2 @@ /** | ||
exports.Vec = Vec; | ||
exports.clone = clone; |
@@ -1,40 +0,27 @@ | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
const oc = Object.prototype.toString; | ||
/** | ||
* | ||
* @param {*} node | ||
* @param {*} o | ||
* @return {*} | ||
*/ | ||
function clone(node) { | ||
if (!node || typeof node != 'object') return node; | ||
switch (true) { | ||
case Array.isArray(node): | ||
return cloneArray(node); | ||
function clone(o) { | ||
if (!o || typeof o !== 'object') return o; | ||
const t = oc.call(o).slice(8, 11); | ||
case node instanceof Date: | ||
return new Date(+node); | ||
// new Date(node.valueOf()) //new Date(+node); | ||
switch (t) { | ||
case 'Arr': | ||
return cloneArray(o); | ||
case node instanceof Map: | ||
return cloneMap(node); | ||
case 'Obj': | ||
return cloneObject(o); | ||
case node instanceof Set: | ||
return new Set(cloneArray([...node])); | ||
case 'Map': | ||
return cloneMap(o); | ||
case node instanceof Object: | ||
return cloneObject(node); | ||
case 'Dat': | ||
return new Date(+o); | ||
case 'Set': | ||
return new Set(cloneArray([...o])); | ||
} | ||
@@ -46,3 +33,3 @@ | ||
* | ||
* @param {Map<*, *>} node | ||
* @param {Map<*, *>} o | ||
* @return {Map<*, *>} | ||
@@ -52,8 +39,8 @@ */ | ||
function cloneMap(node) { | ||
return new Map([...node.entries()].map(([k, v]) => [k, clone(v)])); | ||
function cloneMap(o) { | ||
return new Map([...o.entries()].map(([k, v]) => [k, clone(v)])); | ||
} | ||
/** | ||
* | ||
* @param {*[]} node | ||
* @param {*[]} o | ||
* @return {*[]} | ||
@@ -63,4 +50,4 @@ */ | ||
function cloneArray(node) { | ||
return node.map(clone); | ||
function cloneArray(o) { | ||
return o.map(clone); | ||
} | ||
@@ -70,3 +57,3 @@ /** | ||
* Unable to clone circular and nested object. | ||
* @param {{}} node | ||
* @param {{}} o | ||
* @return {{}} | ||
@@ -76,6 +63,6 @@ */ | ||
function cloneObject(node) { | ||
function cloneObject(o) { | ||
const x = {}; | ||
for (let [k, v] of Object.entries(node)) x[k] = clone(v); | ||
for (let [k, v] of Object.entries(o)) x[k] = clone(v); | ||
@@ -85,2 +72,6 @@ return x; | ||
/** | ||
* Static class containing methods create 1d-array. | ||
*/ | ||
class Vec { | ||
@@ -93,3 +84,3 @@ /** | ||
*/ | ||
static ini(size, ject = i => 0) { | ||
static ini(size, ject) { | ||
if (typeof ject === 'function') { | ||
@@ -118,2 +109,6 @@ if (size <= 128) { | ||
static clone(arr) { | ||
return cloneArray(arr); | ||
} | ||
static indexes(arr) { | ||
@@ -245,12 +240,3 @@ return arr.map((_, i) => i); | ||
} // Array.prototype.zip = function (another, zipper) { | ||
// let ar = []; | ||
// for (let i = 0; i < this.length; i++) { | ||
// ar[i] = zipper(this[i], another[i]) | ||
// } | ||
// return ar | ||
// }; | ||
_defineProperty(Vec, "clone", cloneArray); | ||
// Create an object type VehoError | ||
@@ -273,2 +259,5 @@ class VehoError extends Error { | ||
class Jso { | ||
static clone(o) { | ||
return cloneObject(o); | ||
} | ||
/** | ||
@@ -279,2 +268,4 @@ * | ||
*/ | ||
static toEntries(jso) { | ||
@@ -394,4 +385,2 @@ return Object.entries(jso); | ||
_defineProperty(Jso, "clone", cloneObject); | ||
class JsonTable { | ||
@@ -558,2 +547,17 @@ /** | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
class Dic { | ||
@@ -655,2 +659,2 @@ /** | ||
export { Dic, Fun, Jso, JsonTable, Mat, Vec }; | ||
export { Dic, Fun, Jso, JsonTable, Mat, Vec, clone }; |
@@ -7,131 +7,28 @@ (function (global, factory) { | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _construct(Parent, args, Class) { | ||
if (isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
constructor: { | ||
value: Wrapper, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
return _setPrototypeOf(Wrapper, Class); | ||
}; | ||
return _wrapNativeSuper(Class); | ||
} | ||
var oc = Object.prototype.toString; | ||
/** | ||
* | ||
* @param {*} node | ||
* @param {*} o | ||
* @return {*} | ||
*/ | ||
function clone(node) { | ||
if (!node || typeof node != 'object') return node; | ||
switch (true) { | ||
case Array.isArray(node): | ||
return cloneArray(node); | ||
function clone(o) { | ||
if (!o || typeof o !== 'object') return o; | ||
var t = oc.call(o).slice(8, 11); | ||
case node instanceof Date: | ||
return new Date(+node); | ||
// new Date(node.valueOf()) //new Date(+node); | ||
switch (t) { | ||
case 'Arr': | ||
return cloneArray(o); | ||
case node instanceof Map: | ||
return cloneMap(node); | ||
case 'Obj': | ||
return cloneObject(o); | ||
case node instanceof Set: | ||
return new Set(cloneArray([].concat(node))); | ||
case 'Map': | ||
return cloneMap(o); | ||
case node instanceof Object: | ||
return cloneObject(node); | ||
case 'Dat': | ||
return new Date(+o); | ||
case 'Set': | ||
return new Set(cloneArray([].concat(o))); | ||
} | ||
@@ -143,3 +40,3 @@ | ||
* | ||
* @param {Map<*, *>} node | ||
* @param {Map<*, *>} o | ||
* @return {Map<*, *>} | ||
@@ -149,4 +46,4 @@ */ | ||
function cloneMap(node) { | ||
return new Map([].concat(node.entries()).map(function (_ref) { | ||
function cloneMap(o) { | ||
return new Map([].concat(o.entries()).map(function (_ref) { | ||
var k = _ref[0], | ||
@@ -159,3 +56,3 @@ v = _ref[1]; | ||
* | ||
* @param {*[]} node | ||
* @param {*[]} o | ||
* @return {*[]} | ||
@@ -165,4 +62,4 @@ */ | ||
function cloneArray(node) { | ||
return node.map(clone); | ||
function cloneArray(o) { | ||
return o.map(clone); | ||
} | ||
@@ -172,3 +69,3 @@ /** | ||
* Unable to clone circular and nested object. | ||
* @param {{}} node | ||
* @param {{}} o | ||
* @return {{}} | ||
@@ -178,6 +75,6 @@ */ | ||
function cloneObject(node) { | ||
function cloneObject(o) { | ||
var x = {}; | ||
for (var _i = 0, _Object$entries = Object.entries(node); _i < _Object$entries.length; _i++) { | ||
for (var _i = 0, _Object$entries = Object.entries(o); _i < _Object$entries.length; _i++) { | ||
var _Object$entries$_i = _Object$entries[_i], | ||
@@ -192,2 +89,6 @@ k = _Object$entries$_i[0], | ||
/** | ||
* Static class containing methods create 1d-array. | ||
*/ | ||
var Vec = | ||
@@ -205,8 +106,2 @@ /*#__PURE__*/ | ||
Vec.ini = function ini(size, ject) { | ||
if (ject === void 0) { | ||
ject = function ject(i) { | ||
return 0; | ||
}; | ||
} | ||
if (typeof ject === 'function') { | ||
@@ -241,2 +136,6 @@ if (size <= 128) { | ||
Vec.clone = function clone(arr) { | ||
return cloneArray(arr); | ||
}; | ||
Vec.indexes = function indexes(arr) { | ||
@@ -401,12 +300,108 @@ return arr.map(function (_, i) { | ||
}(); // Array.prototype.zip = function (another, zipper) { | ||
// let ar = []; | ||
// for (let i = 0; i < this.length; i++) { | ||
// ar[i] = zipper(this[i], another[i]) | ||
// } | ||
// return ar | ||
// }; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
_defineProperty(Vec, "clone", cloneArray); | ||
return obj; | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _construct(Parent, args, Class) { | ||
if (isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
constructor: { | ||
value: Wrapper, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
return _setPrototypeOf(Wrapper, Class); | ||
}; | ||
return _wrapNativeSuper(Class); | ||
} | ||
// Create an object type VehoError | ||
@@ -443,2 +438,5 @@ var VehoError = | ||
Jso.clone = function clone(o) { | ||
return cloneObject(o); | ||
} | ||
/** | ||
@@ -449,2 +447,4 @@ * | ||
*/ | ||
; | ||
Jso.toEntries = function toEntries(jso) { | ||
@@ -646,4 +646,2 @@ return Object.entries(jso); | ||
_defineProperty(Jso, "clone", cloneObject); | ||
var JsonTable = | ||
@@ -994,2 +992,3 @@ /*#__PURE__*/ | ||
exports.Vec = Vec; | ||
exports.clone = clone; | ||
@@ -996,0 +995,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
{ | ||
"name": "veho", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"description": "An array extension (grammatical sugar) to create, iterate and query 1d, 2d array and JSON object.", | ||
@@ -41,4 +41,5 @@ "main": "dist/index.cjs.js", | ||
"webpack-cli": "^3.3.9", | ||
"crostab": "^0.1.21", | ||
"elprimero": "^0.0.18", | ||
"xbrief": "^0.1.32" | ||
"xbrief": "^0.1.33" | ||
}, | ||
@@ -45,0 +46,0 @@ "repository": { |
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
1875
54189
21