Socket
Socket
Sign inDemoInstall

z-utils

Package Overview
Dependencies
0
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.6.1 to 1.6.2

src/const.js

188

index.js

@@ -5,3 +5,5 @@ 'use strict';

var isClient = typeof window === "object" && window && window.window === window;
var global = new Function('return this')();
var isClient = typeof window === "object" && window === global;
var isServer = !isClient;

@@ -55,62 +57,56 @@

if (!isNativeFunction(Object.assign)) {
/**
* polyfill es2015 Object.assign
*
* @param {Object} target
* @returns {Object} target
*/
Object.assign = function assign(target/*, ...args*/) {
if (target == null) {
throw new TypeError('Cannot convert undefined or null to object')
}
/**
* polyfill es2015 Object.assign
*
* @param {Object} target
* @returns {Object} target
*/
var assign = isNativeFunction(Object.assign) ? Object.assign : (Object.assign = function assign(target/*, ...args*/) {
if (target == null) {
throw new TypeError('Cannot convert undefined or null to object')
}
var output = Object(target),
i = -1,
args = Array.prototype.slice.call(arguments, 1),
l = args.length;
var output = Object(target),
i = -1,
args = arraySlice.call(arguments, 1),
l = args.length;
while (++i < l) {
var source = args[i];
while (++i < l) {
var source = args[i];
if (source) {
for (var prop in source) {
if (source.hasOwnProperty(prop)) {
output[prop] = source[prop];
}
if (source) {
for (var prop in source) {
if (source.hasOwnProperty(prop)) {
output[prop] = source[prop];
}
}
}
return output
};
}
}
return output
});
var assign = Object.assign;
/**
* polyfill es5 Object.create
*
* @param {Object} object
* @param {Object} props
* @returns {Object} like {__proto__: *}
*/
var create = isNativeFunction(Object.create) ? Object.create : (Object.create = function create(object, props) {
if (object == null || !referenceTypes[typeof object]) {
throw 'Object prototype may only be an Object or null'
}
if (!isNativeFunction(Object.create)) {
/**
* polyfill es5 Object.create
*
* @param {Object} object
* @param {Object} props
* @returns {Object} like {__proto__: *}
*/
Object.create = function create(object, props) {
if (object == null || !referenceTypes[typeof object]) {
throw 'Object prototype may only be an Object or null'
}
var proto = support__proto__ ? {__proto__: object} : (noop.prototype = object, new noop);
var proto = support__proto__ ? {__proto__: object} : (noop.prototype = object, new noop);
if (props) {
if (referenceTypes[typeof props]) {
for (var propName in props) {
if (hasOwnProperty.call(props, propName)) {
var prop = props[propName];
if (props) {
if (referenceTypes[typeof props]) {
for (var propName in props) {
if (hasOwnProperty.call(props, propName)) {
var prop = props[propName];
if (prop && referenceTypes[typeof prop]) {
object[propName] = prop.value;
} else {
throw 'Property description must be an object: value'
}
if (prop && referenceTypes[typeof prop]) {
object[propName] = prop.value;
} else {
throw 'Property description must be an object: value'
}

@@ -120,28 +116,16 @@ }

}
return proto
};
}
}
return proto
});
var create = Object.create;
/**
* get global object
* @return {Object} global
* polyfill es5 Array.isArray
*
* @param {Array} arg
* @returns {Boolean}
*/
var global = new Function('return this || (typeof global === "object" && global && global.global === global ? global : window)')();
var isArray = isNativeFunction(Array.isArray) ? Array.isArray : (Array.isArray = function isArray(arg) {
return toString.call(arg) === '[object Array]'
});
if (!isNativeFunction(Array.isArray)) {
/**
* polyfill es5 Array.isArray
*
* @param {Array} arg
* @returns {Boolean}
*/
Array.isArray = function isArray(arg) {
return toString.call(arg) === '[object Array]'
};
}
var isArray = Array.isArray;
/**

@@ -179,3 +163,3 @@ * test an object use 'for in'

*/
function isPlainObject(object) {
function isPlainObject (object) {
// Must be an Object.

@@ -188,19 +172,29 @@ // Because of IE, we also have to check the presence of the constructor property.

if (object.constructor && !hasOwnProperty.call(object, "constructor") && !hasOwnProperty.call(object.constructor.prototype, "isPrototypeOf")) {
return false;
return false
}
} catch (e) {
// IE8,9 Will throw exceptions on certain host objects
return false;
return false
}
if (!firstTraverseOwnProperty) {
for (var k$1 in object) {
return hasOwnProperty.call(object, k$1)
var k;
if (firstTraverseOwnProperty) {
for (k in object) {
0; // fix rollup bug
}
return true
return typeof k !== 'string' || hasOwnProperty.call(object, k)
}
return k === undefined || hasOwnProperty.call(object, k)
for (k in object) {
return hasOwnProperty.call(object, k)
}
return true
}
if (!isNativeFunction(Object.keys)) {
var keys = isNativeFunction(Object.keys) ? Object.keys : function () {
var unableEnumerateOwnKeys, key;
for (key in {toString: 1}) {
0; // fix rollup bug
break
}
// IE 某些属性即便为自身属性也无法枚举
key || (unableEnumerateOwnKeys = 'constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf'.split(' '));

@@ -214,20 +208,18 @@

*/
Object.keys = function keys (object) {
return (Object.keys = function keys (object) {
var arrkeys = [], key, l, i;
if( unableEnumerateOwnKeys ){
if (unableEnumerateOwnKeys) {
l = unableEnumerateOwnKeys.length;
i = -1;
while( ++i < l ){
hasOwnProperty.call(object, unableEnumerateOwnKeys[i]) && (arrkeys[ l++ ] = unableEnumerateOwnKeys[i]);
while (++i < l) {
hasOwnProperty.call(object, unableEnumerateOwnKeys[i]) && (arrkeys[l++] = unableEnumerateOwnKeys[i]);
}
}
for( key in object ){
hasOwnProperty.call(object, key) && (arrkeys[ l++ ] = key);
for (key in object) {
hasOwnProperty.call(object, key) && (arrkeys[l++] = key);
}
return arrkeys
};
}
})
}();
var keys = Object.keys;
/**

@@ -296,3 +288,3 @@ * object deep merge

*/
var namespace = (Object.ns = Object.namespace = function namespace (root, sNamespace, variable) {
function namespace (root, sNamespace, variable) {
// 变量判断转化

@@ -328,6 +320,4 @@ if (typeof root === 'string') {

return (root[namespaces[l]] = variable)
});
}
var slice = Array.prototype.slice;
function toArray (object, startIndex, endIndex) {

@@ -337,3 +327,3 @@ if (object == null) {

}
return slice.call(object, startIndex, endIndex)
return arraySlice.call(object, startIndex, endIndex)
}

@@ -366,3 +356,3 @@

function S4() {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
return (((1 + Math.random()) * 0x10000) | 0).toString(16).slice(1)
}

@@ -380,3 +370,2 @@

exports.create = create;
exports.global = global;
exports.isArray = isArray;

@@ -392,2 +381,3 @@ exports.isEmptyObject = isEmptyObject;

exports.uuid = uuid;
exports.global = global;
exports.isClient = isClient;

@@ -394,0 +384,0 @@ exports.isServer = isServer;

{
"name": "z-utils",
"version": "1.6.1",
"version": "1.6.2",
"description": "javascript uitls",

@@ -26,2 +26,3 @@ "scripts": {

"devDependencies": {
"babel-core": "^6.26.0",
"rollup": "^0.49.1",

@@ -28,0 +29,0 @@ "rollup-plugin-babel": "^3.0.2",

import isNativeFunction from './isNativeFunction'
import {arraySlice} from './const'
if (!isNativeFunction(Object.assign)) {
/**
* polyfill es2015 Object.assign
*
* @param {Object} target
* @returns {Object} target
*/
Object.assign = function assign(target/*, ...args*/) {
if (target == null) {
throw new TypeError('Cannot convert undefined or null to object')
}
/**
* polyfill es2015 Object.assign
*
* @param {Object} target
* @returns {Object} target
*/
export default isNativeFunction(Object.assign) ? Object.assign : (Object.assign = function assign(target/*, ...args*/) {
if (target == null) {
throw new TypeError('Cannot convert undefined or null to object')
}
let output = Object(target),
i = -1,
args = Array.prototype.slice.call(arguments, 1),
l = args.length
let output = Object(target),
i = -1,
args = arraySlice.call(arguments, 1),
l = args.length
while (++i < l) {
let source = args[i]
while (++i < l) {
let source = args[i]
if (source) {
for (let prop in source) {
if (source.hasOwnProperty(prop)) {
output[prop] = source[prop]
}
if (source) {
for (let prop in source) {
if (source.hasOwnProperty(prop)) {
output[prop] = source[prop]
}
}
}
return output
}
}
export default Object.assign
return output
})
import isNativeFunction from './isNativeFunction'
import {hasOwnProperty, noop, referenceTypes, support__proto__} from './core'
import {hasOwnProperty, noop, referenceTypes, support__proto__} from './const'
if (!isNativeFunction(Object.create)) {
/**
* polyfill es5 Object.create
*
* @param {Object} object
* @param {Object} props
* @returns {Object} like {__proto__: *}
*/
Object.create = function create(object, props) {
if (object == null || !referenceTypes[typeof object]) {
throw 'Object prototype may only be an Object or null'
}
/**
* polyfill es5 Object.create
*
* @param {Object} object
* @param {Object} props
* @returns {Object} like {__proto__: *}
*/
export default isNativeFunction(Object.create) ? Object.create : (Object.create = function create(object, props) {
if (object == null || !referenceTypes[typeof object]) {
throw 'Object prototype may only be an Object or null'
}
let proto = support__proto__ ? {__proto__: object} : (noop.prototype = object, new noop)
let proto = support__proto__ ? {__proto__: object} : (noop.prototype = object, new noop)
if (props) {
if (referenceTypes[typeof props]) {
for (let propName in props) {
if (hasOwnProperty.call(props, propName)) {
let prop = props[propName]
if (props) {
if (referenceTypes[typeof props]) {
for (let propName in props) {
if (hasOwnProperty.call(props, propName)) {
let prop = props[propName]
if (prop && referenceTypes[typeof prop]) {
object[propName] = prop.value
} else {
throw 'Property description must be an object: value'
}
if (prop && referenceTypes[typeof prop]) {
object[propName] = prop.value
} else {
throw 'Property description must be an object: value'
}

@@ -34,6 +32,4 @@ }

}
return proto
}
}
export default Object.create
return proto
})
export {default as assign} from './assign'
export {default as create} from './create'
export {default as global} from './global'
export {default as isArray} from './isArray'

@@ -14,2 +13,3 @@ export {default as isEmptyObject} from './isEmptyObject'

export {default as uuid} from './uuid'
export * from './core'
export * from './const'
export * from './core'
import isNativeFunction from './isNativeFunction'
import {toString} from './core'
import {toString} from './const'
if (!isNativeFunction(Array.isArray)) {
/**
* polyfill es5 Array.isArray
*
* @param {Array} arg
* @returns {Boolean}
*/
Array.isArray = function isArray(arg) {
return toString.call(arg) === '[object Array]'
}
}
export default Array.isArray
/**
* polyfill es5 Array.isArray
*
* @param {Array} arg
* @returns {Boolean}
*/
export default isNativeFunction(Array.isArray) ? Array.isArray : (Array.isArray = function isArray(arg) {
return toString.call(arg) === '[object Array]'
})

@@ -1,2 +0,2 @@

import {toString} from './core'
import {toString} from './const'

@@ -3,0 +3,0 @@ const sNativeCode = (isNaN + '').slice((isNaN + '').indexOf('{'))

@@ -1,2 +0,2 @@

import {hasOwnProperty, toString} from './core'
import {hasOwnProperty, toString} from './const'
import create from './create'

@@ -23,3 +23,3 @@

*/
export default function isPlainObject(object) {
export default function isPlainObject (object) {
// Must be an Object.

@@ -32,16 +32,19 @@ // Because of IE, we also have to check the presence of the constructor property.

if (object.constructor && !hasOwnProperty.call(object, "constructor") && !hasOwnProperty.call(object.constructor.prototype, "isPrototypeOf")) {
return false;
return false
}
} catch (e) {
// IE8,9 Will throw exceptions on certain host objects
return false;
return false
}
if (!firstTraverseOwnProperty) {
for (let k in object) {
return hasOwnProperty.call(object, k)
let k
if (firstTraverseOwnProperty) {
for (k in object) {
0 // fix rollup bug
}
return true
return typeof k !== 'string' || hasOwnProperty.call(object, k)
}
for (let k in object) {}
return k === undefined || hasOwnProperty.call(object, k)
for (k in object) {
return hasOwnProperty.call(object, k)
}
return true
}
import isNativeFunction from './isNativeFunction'
import {hasOwnProperty} from './core'
import {hasOwnProperty} from './const'
if (!isNativeFunction(Object.keys)) {
export default isNativeFunction(Object.keys) ? Object.keys : function () {
let unableEnumerateOwnKeys, key
for (key in {toString: 1}) break
for (key in {toString: 1}) {
0 // fix rollup bug
break
}

@@ -17,18 +20,16 @@ // IE 某些属性即便为自身属性也无法枚举

*/
Object.keys = function keys (object) {
return (Object.keys = function keys (object) {
let arrkeys = [], key, l, i
if( unableEnumerateOwnKeys ){
if (unableEnumerateOwnKeys) {
l = unableEnumerateOwnKeys.length
i = -1
while( ++i < l ){
hasOwnProperty.call(object, unableEnumerateOwnKeys[i]) && (arrkeys[ l++ ] = unableEnumerateOwnKeys[i])
while (++i < l) {
hasOwnProperty.call(object, unableEnumerateOwnKeys[i]) && (arrkeys[l++] = unableEnumerateOwnKeys[i])
}
}
for( key in object ){
hasOwnProperty.call(object, key) && (arrkeys[ l++ ] = key)
for (key in object) {
hasOwnProperty.call(object, key) && (arrkeys[l++] = key)
}
return arrkeys
}
}
export default Object.keys
})
}()

@@ -1,2 +0,2 @@

import global from './global'
import {global} from './const'

@@ -7,3 +7,3 @@ /**

*/
export default (Object.ns = Object.namespace = function namespace (root, sNamespace, variable) {
export default function namespace (root, sNamespace, variable) {
// 变量判断转化

@@ -39,2 +39,2 @@ if (typeof root === 'string') {

return (root[namespaces[l]] = variable)
})
}

@@ -1,2 +0,2 @@

const slice = Array.prototype.slice
import {arraySlice} from './const'

@@ -7,3 +7,3 @@ export default function toArray (object, startIndex, endIndex) {

}
return slice.call(object, startIndex, endIndex)
return arraySlice.call(object, startIndex, endIndex)
}

@@ -1,2 +0,2 @@

import {toString} from './core'
import {toString} from './const'

@@ -3,0 +3,0 @@ /**

@@ -17,3 +17,3 @@

function S4() {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
return (((1 + Math.random()) * 0x10000) | 0).toString(16).slice(1)
}

@@ -20,0 +20,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc