to-length-x
Advanced tools
Comparing version 1.1.0 to 1.1.1
38
index.js
@@ -25,22 +25,9 @@ /** | ||
* | ||
* toLength module. | ||
* ToLength converts argument to an integer suitable for use as the length of an array-like object. | ||
* | ||
* <h2>ECMAScript compatibility shims for legacy JavaScript engines</h2> | ||
* `es5-shim.js` monkey-patches a JavaScript context to contain all EcmaScript 5 | ||
* methods that can be faithfully emulated with a legacy JavaScript engine. | ||
* Requires ES3 or above. | ||
* | ||
* `es5-sham.js` monkey-patches other ES5 methods as closely as possible. | ||
* For these methods, as closely as possible to ES5 is not very close. | ||
* Many of these shams are intended only to allow code to be written to ES5 | ||
* without causing run-time errors in older engines. In many cases, | ||
* this means that these shams cause many ES5 methods to silently fail. | ||
* Decide carefully whether this is what you want. Note: es5-sham.js requires | ||
* es5-shim.js to be able to work properly. | ||
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-tolength|7.1.15 ToLength ( argument )} | ||
* | ||
* `json3.js` monkey-patches the EcmaScript 5 JSON implimentation faithfully. | ||
* | ||
* `es6.shim.js` provides compatibility shims so that legacy JavaScript engines | ||
* behave as closely as possible to ECMAScript 6 (Harmony). | ||
* | ||
* @version 1.1.0 | ||
* @version 1.1.1 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
@@ -52,13 +39,5 @@ * @copyright Xotic750 | ||
/* jslint maxlen:80, es6:true, white:true */ | ||
/* jshint bitwise:true, camelcase:true, curly:true, eqeqeq:true, forin:true, | ||
freeze:true, futurehostile:true, latedef:true, newcap:true, nocomma:true, | ||
nonbsp:true, singleGroups:true, strict:true, undef:true, unused:true, | ||
es3:false, esnext:true, plusplus:true, maxparams:1, maxdepth:1, | ||
maxstatements:3, maxcomplexity:2 */ | ||
/* eslint strict: 1, max-statements: 1 */ | ||
/* global require, module */ | ||
/* global module */ | ||
@@ -70,4 +49,3 @@ ;(function () { // eslint-disable-line no-extra-semi | ||
var toInteger = require('to-integer-x'); | ||
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER; | ||
var zero = 0; | ||
var MAX_SAFE_INTEGER = 9007199254740991; | ||
@@ -89,4 +67,4 @@ /** | ||
var len = toInteger(value); | ||
if (len <= zero) { | ||
return zero; | ||
if (len <= 0) { | ||
return 0; | ||
} // includes converting -0 to +0 | ||
@@ -93,0 +71,0 @@ if (len > MAX_SAFE_INTEGER) { |
@@ -26,22 +26,9 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.returnExports = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
* | ||
* toLength module. | ||
* ToLength converts argument to an integer suitable for use as the length of an array-like object. | ||
* | ||
* <h2>ECMAScript compatibility shims for legacy JavaScript engines</h2> | ||
* `es5-shim.js` monkey-patches a JavaScript context to contain all EcmaScript 5 | ||
* methods that can be faithfully emulated with a legacy JavaScript engine. | ||
* Requires ES3 or above. | ||
* | ||
* `es5-sham.js` monkey-patches other ES5 methods as closely as possible. | ||
* For these methods, as closely as possible to ES5 is not very close. | ||
* Many of these shams are intended only to allow code to be written to ES5 | ||
* without causing run-time errors in older engines. In many cases, | ||
* this means that these shams cause many ES5 methods to silently fail. | ||
* Decide carefully whether this is what you want. Note: es5-sham.js requires | ||
* es5-shim.js to be able to work properly. | ||
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-tolength|7.1.15 ToLength ( argument )} | ||
* | ||
* `json3.js` monkey-patches the EcmaScript 5 JSON implimentation faithfully. | ||
* | ||
* `es6.shim.js` provides compatibility shims so that legacy JavaScript engines | ||
* behave as closely as possible to ECMAScript 6 (Harmony). | ||
* | ||
* @version 1.1.0 | ||
* @version 1.1.1 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
@@ -53,13 +40,5 @@ * @copyright Xotic750 | ||
/* jslint maxlen:80, es6:true, white:true */ | ||
/* jshint bitwise:true, camelcase:true, curly:true, eqeqeq:true, forin:true, | ||
freeze:true, futurehostile:true, latedef:true, newcap:true, nocomma:true, | ||
nonbsp:true, singleGroups:true, strict:true, undef:true, unused:true, | ||
es3:false, esnext:true, plusplus:true, maxparams:1, maxdepth:1, | ||
maxstatements:3, maxcomplexity:2 */ | ||
/* eslint strict: 1, max-statements: 1 */ | ||
/* global require, module */ | ||
/* global module */ | ||
@@ -71,4 +50,3 @@ ;(function () { // eslint-disable-line no-extra-semi | ||
var toInteger = _dereq_('to-integer-x'); | ||
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER; | ||
var zero = 0; | ||
var MAX_SAFE_INTEGER = 9007199254740991; | ||
@@ -90,4 +68,4 @@ /** | ||
var len = toInteger(value); | ||
if (len <= zero) { | ||
return zero; | ||
if (len <= 0) { | ||
return 0; | ||
} // includes converting -0 to +0 | ||
@@ -101,5 +79,469 @@ if (len > MAX_SAFE_INTEGER) { | ||
},{"to-integer-x":2}],2:[function(_dereq_,module,exports){ | ||
},{"to-integer-x":12}],2:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var keys = _dereq_('object-keys'); | ||
var foreach = _dereq_('foreach'); | ||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'; | ||
var toStr = Object.prototype.toString; | ||
var isFunction = function (fn) { | ||
return typeof fn === 'function' && toStr.call(fn) === '[object Function]'; | ||
}; | ||
var arePropertyDescriptorsSupported = function () { | ||
var obj = {}; | ||
try { | ||
Object.defineProperty(obj, 'x', { enumerable: false, value: obj }); | ||
/* eslint-disable no-unused-vars, no-restricted-syntax */ | ||
for (var _ in obj) { return false; } | ||
/* eslint-enable no-unused-vars, no-restricted-syntax */ | ||
return obj.x === obj; | ||
} catch (e) { /* this is IE 8. */ | ||
return false; | ||
} | ||
}; | ||
var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported(); | ||
var defineProperty = function (object, name, value, predicate) { | ||
if (name in object && (!isFunction(predicate) || !predicate())) { | ||
return; | ||
} | ||
if (supportsDescriptors) { | ||
Object.defineProperty(object, name, { | ||
configurable: true, | ||
enumerable: false, | ||
value: value, | ||
writable: true | ||
}); | ||
} else { | ||
object[name] = value; | ||
} | ||
}; | ||
var defineProperties = function (object, map) { | ||
var predicates = arguments.length > 2 ? arguments[2] : {}; | ||
var props = keys(map); | ||
if (hasSymbols) { | ||
props = props.concat(Object.getOwnPropertySymbols(map)); | ||
} | ||
foreach(props, function (name) { | ||
defineProperty(object, name, map[name], predicates[name]); | ||
}); | ||
}; | ||
defineProperties.supportsDescriptors = !!supportsDescriptors; | ||
module.exports = defineProperties; | ||
},{"foreach":3,"object-keys":10}],3:[function(_dereq_,module,exports){ | ||
var hasOwn = Object.prototype.hasOwnProperty; | ||
var toString = Object.prototype.toString; | ||
module.exports = function forEach (obj, fn, ctx) { | ||
if (toString.call(fn) !== '[object Function]') { | ||
throw new TypeError('iterator must be a function'); | ||
} | ||
var l = obj.length; | ||
if (l === +l) { | ||
for (var i = 0; i < l; i++) { | ||
fn.call(ctx, obj[i], i, obj); | ||
} | ||
} else { | ||
for (var k in obj) { | ||
if (hasOwn.call(obj, k)) { | ||
fn.call(ctx, obj[k], k, obj); | ||
} | ||
} | ||
} | ||
}; | ||
},{}],4:[function(_dereq_,module,exports){ | ||
/** | ||
* @file | ||
* <a href="https://travis-ci.org/Xotic750/is-finite-x" | ||
* title="Travis status"> | ||
* <img | ||
* src="https://travis-ci.org/Xotic750/is-finite-x.svg?branch=master" | ||
* alt="Travis status" height="18"> | ||
* </a> | ||
* <a href="https://david-dm.org/Xotic750/is-finite-x" | ||
* title="Dependency status"> | ||
* <img src="https://david-dm.org/Xotic750/is-finite-x.svg" | ||
* alt="Dependency status" height="18"/> | ||
* </a> | ||
* <a | ||
* href="https://david-dm.org/Xotic750/is-finite-x#info=devDependencies" | ||
* title="devDependency status"> | ||
* <img src="https://david-dm.org/Xotic750/is-finite-x/dev-status.svg" | ||
* alt="devDependency status" height="18"/> | ||
* </a> | ||
* <a href="https://badge.fury.io/js/is-finite-x" title="npm version"> | ||
* <img src="https://badge.fury.io/js/is-finite-x.svg" | ||
* alt="npm version" height="18"> | ||
* </a> | ||
* | ||
* ES6-compliant shim for Number.isFinite. | ||
* | ||
* Requires ES3 or above. | ||
* | ||
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-number.isfinite|20.1.2.2 Number.isFinite ( number )} | ||
* | ||
* @version 1.0.0 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
* @copyright Xotic750 | ||
* @license {@link <https://opensource.org/licenses/MIT> MIT} | ||
* @module is-finite-x | ||
*/ | ||
/* eslint strict: 1 */ | ||
/* global module */ | ||
;(function () { // eslint-disable-line no-extra-semi | ||
'use strict'; | ||
var $isNaN = _dereq_('is-nan'); | ||
var $isFinite; | ||
if (typeof Number.isFinite === 'function') { | ||
try { | ||
if (Number.isFinite(9007199254740991) && !Number.isFinite(Infinity)) { | ||
$isFinite = Number.isFinite; | ||
} | ||
} catch (ignore) {} | ||
} | ||
/** | ||
* This method determines whether the passed value is a finite number. | ||
* | ||
* @param {*} number The value to be tested for finiteness. | ||
* @return {boolean} A Boolean indicating whether or not the given value is a finite number. | ||
* @example | ||
* var numIsFinite = require('is-finite-x'); | ||
* | ||
* numIsFinite(Infinity); // false | ||
* numIsFinite(NaN); // false | ||
* numIsFinite(-Infinity); // false | ||
* | ||
* numIsFinite(0); // true | ||
* numIsFinite(2e64); // true | ||
* | ||
* numIsFinite('0'); // false, would've been true with | ||
* // global isFinite('0') | ||
* numIsFinite(null); // false, would've been true with | ||
*/ | ||
module.exports = $isFinite || function isFinite(number) { | ||
return !(typeof number !== 'number' || $isNaN(number) || number === Infinity || number === -Infinity); | ||
}; | ||
}()); | ||
},{"is-nan":6}],5:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
/* http://www.ecma-international.org/ecma-262/6.0/#sec-number.isnan */ | ||
module.exports = function isNaN(value) { | ||
return value !== value; | ||
}; | ||
},{}],6:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var define = _dereq_('define-properties'); | ||
var implementation = _dereq_('./implementation'); | ||
var getPolyfill = _dereq_('./polyfill'); | ||
var shim = _dereq_('./shim'); | ||
/* http://www.ecma-international.org/ecma-262/6.0/#sec-number.isnan */ | ||
define(implementation, { | ||
getPolyfill: getPolyfill, | ||
implementation: implementation, | ||
shim: shim | ||
}); | ||
module.exports = implementation; | ||
},{"./implementation":5,"./polyfill":7,"./shim":8,"define-properties":2}],7:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var implementation = _dereq_('./implementation'); | ||
module.exports = function getPolyfill() { | ||
if (Number.isNaN && Number.isNaN(NaN) && !Number.isNaN('a')) { | ||
return Number.isNaN; | ||
} | ||
return implementation; | ||
}; | ||
},{"./implementation":5}],8:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var define = _dereq_('define-properties'); | ||
var getPolyfill = _dereq_('./polyfill'); | ||
/* http://www.ecma-international.org/ecma-262/6.0/#sec-number.isnan */ | ||
module.exports = function shimNumberIsNaN() { | ||
var polyfill = getPolyfill(); | ||
define(Number, { isNaN: polyfill }, { isNaN: function () { return Number.isNaN !== polyfill; } }); | ||
return polyfill; | ||
}; | ||
},{"./polyfill":7,"define-properties":2}],9:[function(_dereq_,module,exports){ | ||
/** | ||
* @file | ||
* <a href="https://travis-ci.org/Xotic750/math-sign-x" | ||
* title="Travis status"> | ||
* <img | ||
* src="https://travis-ci.org/Xotic750/math-sign-x.svg?branch=master" | ||
* alt="Travis status" height="18"> | ||
* </a> | ||
* <a href="https://david-dm.org/Xotic750/math-sign-x" | ||
* title="Dependency status"> | ||
* <img src="https://david-dm.org/Xotic750/math-sign-x.svg" | ||
* alt="Dependency status" height="18"/> | ||
* </a> | ||
* <a | ||
* href="https://david-dm.org/Xotic750/math-sign-x#info=devDependencies" | ||
* title="devDependency status"> | ||
* <img src="https://david-dm.org/Xotic750/math-sign-x/dev-status.svg" | ||
* alt="devDependency status" height="18"/> | ||
* </a> | ||
* <a href="https://badge.fury.io/js/math-sign-x" title="npm version"> | ||
* <img src="https://badge.fury.io/js/math-sign-x.svg" | ||
* alt="npm version" height="18"> | ||
* </a> | ||
* | ||
* ES6-compliant shim for Math.sign. | ||
* | ||
* Requires ES3 or above. | ||
* | ||
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-math.sign|20.2.2.29 Math.sign(x)} | ||
* | ||
* @version 1.0.0 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
* @copyright Xotic750 | ||
* @license {@link <https://opensource.org/licenses/MIT> MIT} | ||
* @module math-sign-x | ||
*/ | ||
/* eslint strict: 1 */ | ||
/* global module */ | ||
;(function () { // eslint-disable-line no-extra-semi | ||
'use strict'; | ||
var $isNaN = _dereq_('is-nan'); | ||
var $sign; | ||
if (typeof Math.sign === 'function') { | ||
try { | ||
if (Math.sign(10) === 1 && Math.sign(-10) === -1 && Math.sign(0) === 0) { | ||
$sign = Math.sign; | ||
} | ||
} catch (ignore) {} | ||
} | ||
/** | ||
* This method returns the sign of a number, indicating whether the number is positive, | ||
* negative or zero. | ||
* | ||
* @param {*} x A number. | ||
* @return {number} A number representing the sign of the given argument. If the argument | ||
* is a positive number, negative number, positive zero or negative zero, the function will | ||
* return 1, -1, 0 or -0 respectively. Otherwise, NaN is returned. | ||
* @example | ||
* var mathSign = require('math-sign-x'); | ||
* | ||
* mathSign(3); // 1 | ||
* mathSign(-3); // -1 | ||
* mathSign('-3'); // -1 | ||
* mathSign(0); // 0 | ||
* mathSign(-0); // -0 | ||
* mathSign(NaN); // NaN | ||
* mathSign('foo'); // NaN | ||
* mathSign(); // NaN | ||
*/ | ||
module.exports = $sign || function sign(x) { | ||
var n = Number(x); | ||
if (n === 0 || $isNaN(n)) { | ||
return n; | ||
} | ||
return n > 0 ? 1 : -1; | ||
}; | ||
}()); | ||
},{"is-nan":6}],10:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
// modified from https://github.com/es-shims/es5-shim | ||
var has = Object.prototype.hasOwnProperty; | ||
var toStr = Object.prototype.toString; | ||
var slice = Array.prototype.slice; | ||
var isArgs = _dereq_('./isArguments'); | ||
var isEnumerable = Object.prototype.propertyIsEnumerable; | ||
var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString'); | ||
var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype'); | ||
var dontEnums = [ | ||
'toString', | ||
'toLocaleString', | ||
'valueOf', | ||
'hasOwnProperty', | ||
'isPrototypeOf', | ||
'propertyIsEnumerable', | ||
'constructor' | ||
]; | ||
var equalsConstructorPrototype = function (o) { | ||
var ctor = o.constructor; | ||
return ctor && ctor.prototype === o; | ||
}; | ||
var excludedKeys = { | ||
$console: true, | ||
$external: true, | ||
$frame: true, | ||
$frameElement: true, | ||
$frames: true, | ||
$innerHeight: true, | ||
$innerWidth: true, | ||
$outerHeight: true, | ||
$outerWidth: true, | ||
$pageXOffset: true, | ||
$pageYOffset: true, | ||
$parent: true, | ||
$scrollLeft: true, | ||
$scrollTop: true, | ||
$scrollX: true, | ||
$scrollY: true, | ||
$self: true, | ||
$webkitIndexedDB: true, | ||
$webkitStorageInfo: true, | ||
$window: true | ||
}; | ||
var hasAutomationEqualityBug = (function () { | ||
/* global window */ | ||
if (typeof window === 'undefined') { return false; } | ||
for (var k in window) { | ||
try { | ||
if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { | ||
try { | ||
equalsConstructorPrototype(window[k]); | ||
} catch (e) { | ||
return true; | ||
} | ||
} | ||
} catch (e) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}()); | ||
var equalsConstructorPrototypeIfNotBuggy = function (o) { | ||
/* global window */ | ||
if (typeof window === 'undefined' || !hasAutomationEqualityBug) { | ||
return equalsConstructorPrototype(o); | ||
} | ||
try { | ||
return equalsConstructorPrototype(o); | ||
} catch (e) { | ||
return false; | ||
} | ||
}; | ||
var keysShim = function keys(object) { | ||
var isObject = object !== null && typeof object === 'object'; | ||
var isFunction = toStr.call(object) === '[object Function]'; | ||
var isArguments = isArgs(object); | ||
var isString = isObject && toStr.call(object) === '[object String]'; | ||
var theKeys = []; | ||
if (!isObject && !isFunction && !isArguments) { | ||
throw new TypeError('Object.keys called on a non-object'); | ||
} | ||
var skipProto = hasProtoEnumBug && isFunction; | ||
if (isString && object.length > 0 && !has.call(object, 0)) { | ||
for (var i = 0; i < object.length; ++i) { | ||
theKeys.push(String(i)); | ||
} | ||
} | ||
if (isArguments && object.length > 0) { | ||
for (var j = 0; j < object.length; ++j) { | ||
theKeys.push(String(j)); | ||
} | ||
} else { | ||
for (var name in object) { | ||
if (!(skipProto && name === 'prototype') && has.call(object, name)) { | ||
theKeys.push(String(name)); | ||
} | ||
} | ||
} | ||
if (hasDontEnumBug) { | ||
var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); | ||
for (var k = 0; k < dontEnums.length; ++k) { | ||
if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) { | ||
theKeys.push(dontEnums[k]); | ||
} | ||
} | ||
} | ||
return theKeys; | ||
}; | ||
keysShim.shim = function shimObjectKeys() { | ||
if (Object.keys) { | ||
var keysWorksWithArguments = (function () { | ||
// Safari 5.0 bug | ||
return (Object.keys(arguments) || '').length === 2; | ||
}(1, 2)); | ||
if (!keysWorksWithArguments) { | ||
var originalKeys = Object.keys; | ||
Object.keys = function keys(object) { | ||
if (isArgs(object)) { | ||
return originalKeys(slice.call(object)); | ||
} else { | ||
return originalKeys(object); | ||
} | ||
}; | ||
} | ||
} else { | ||
Object.keys = keysShim; | ||
} | ||
return Object.keys || keysShim; | ||
}; | ||
module.exports = keysShim; | ||
},{"./isArguments":11}],11:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var toStr = Object.prototype.toString; | ||
module.exports = function isArguments(value) { | ||
var str = toStr.call(value); | ||
var isArgs = str === '[object Arguments]'; | ||
if (!isArgs) { | ||
isArgs = str !== '[object Array]' && | ||
value !== null && | ||
typeof value === 'object' && | ||
typeof value.length === 'number' && | ||
value.length >= 0 && | ||
toStr.call(value.callee) === '[object Function]'; | ||
} | ||
return isArgs; | ||
}; | ||
},{}],12:[function(_dereq_,module,exports){ | ||
/** | ||
* @file | ||
* <a href="https://travis-ci.org/Xotic750/to-integer-x" | ||
@@ -127,22 +569,9 @@ * title="Travis status"> | ||
* | ||
* toInteger module. | ||
* ES6-compliant shim for toInteger. | ||
* | ||
* <h2>ECMAScript compatibility shims for legacy JavaScript engines</h2> | ||
* `es5-shim.js` monkey-patches a JavaScript context to contain all EcmaScript 5 | ||
* methods that can be faithfully emulated with a legacy JavaScript engine. | ||
* Requires ES3 or above. | ||
* | ||
* `es5-sham.js` monkey-patches other ES5 methods as closely as possible. | ||
* For these methods, as closely as possible to ES5 is not very close. | ||
* Many of these shams are intended only to allow code to be written to ES5 | ||
* without causing run-time errors in older engines. In many cases, | ||
* this means that these shams cause many ES5 methods to silently fail. | ||
* Decide carefully whether this is what you want. Note: es5-sham.js requires | ||
* es5-shim.js to be able to work properly. | ||
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger|7.1.4 ToInteger ( argument )} | ||
* | ||
* `json3.js` monkey-patches the EcmaScript 5 JSON implimentation faithfully. | ||
* | ||
* `es6.shim.js` provides compatibility shims so that legacy JavaScript engines | ||
* behave as closely as possible to ECMAScript 6 (Harmony). | ||
* | ||
* @version 1.1.1 | ||
* @version 1.1.3 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
@@ -154,12 +583,4 @@ * @copyright Xotic750 | ||
/* jslint maxlen:80, es6:true, white:true */ | ||
/* eslint strict: 1 */ | ||
/* jshint bitwise:true, camelcase:true, curly:true, eqeqeq:true, forin:true, | ||
freeze:true, futurehostile:true, latedef:true, newcap:true, nocomma:true, | ||
nonbsp:true, singleGroups:true, strict:true, undef:true, unused:true, | ||
es3:true, esnext:true, plusplus:true, maxparams:1, maxdepth:1, | ||
maxstatements:7, maxcomplexity:4 */ | ||
/* eslint strict: 1, max-statements: 1 */ | ||
/* global module */ | ||
@@ -171,9 +592,5 @@ | ||
var $Number = Number; | ||
var $isNaN = Number.isNaN; | ||
var $isFinite = Number.isFinite; | ||
var $sign = Math.sign; | ||
var $floor = Math.floor; | ||
var $abs = Math.abs; | ||
var zero = 0; | ||
var $isNaN = _dereq_('is-nan'); | ||
var $isFinite = _dereq_('is-finite-x'); | ||
var $sign = _dereq_('math-sign-x'); | ||
@@ -185,2 +602,3 @@ /** | ||
* @return {number} Returns the converted integer. | ||
* | ||
* @example | ||
@@ -194,14 +612,14 @@ * var toInteger = require('to-integer-x'); | ||
module.exports = function toInteger(value) { | ||
var number = $Number(value); | ||
var number = Number(value); | ||
if ($isNaN(number)) { | ||
return zero; | ||
return 0; | ||
} | ||
if (number === zero || !$isFinite(number)) { | ||
if (number === 0 || !$isFinite(number)) { | ||
return number; | ||
} | ||
return $sign(number) * $floor($abs(number)); | ||
return $sign(number) * Math.floor(Math.abs(number)); | ||
}; | ||
}()); | ||
},{}]},{},[1])(1) | ||
},{"is-finite-x":4,"is-nan":6,"math-sign-x":9}]},{},[1])(1) | ||
}); |
@@ -1,2 +0,2 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.returnExports=e()}}(function(){return function e(n,t,r){function s(i,f){if(!t[i]){if(!n[i]){var u="function"==typeof require&&require;if(!f&&u)return u(i,!0);if(o)return o(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var c=t[i]={exports:{}};n[i][0].call(c.exports,function(e){var t=n[i][1][e];return s(t?t:e)},c,c.exports,e,n,t,r)}return t[i].exports}for(var o="function"==typeof require&&require,i=0;i<r.length;i++)s(r[i]);return s}({1:[function(e,n,t){!function(){"use strict";var t=e("to-integer-x"),r=Number.MAX_SAFE_INTEGER,o=0;n.exports=function toLength(e){var n=t(e);return n<=o?o:n>r?r:n}}()},{"to-integer-x":2}],2:[function(e,n,t){!function(){"use strict";var e=Number,t=Number.isNaN,r=Number.isFinite,o=Math.sign,i=Math.floor,f=Math.abs,u=0;n.exports=function toInteger(n){var s=e(n);return t(s)?u:s!==u&&r(s)?o(s)*i(f(s)):s}}()},{}]},{},[1])(1)}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.returnExports=t()}}(function(){return function e(t,n,r){function s(i,u){if(!n[i]){if(!t[i]){var c="function"==typeof require&&require;if(!u&&c)return c(i,!0);if(o)return o(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var a=n[i]={exports:{}};t[i][0].call(a.exports,function(e){var n=t[i][1][e];return s(n?n:e)},a,a.exports,e,t,n,r)}return n[i].exports}for(var o="function"==typeof require&&require,i=0;i<r.length;i++)s(r[i]);return s}({1:[function(t,e,n){!function(){"use strict";var n=t("to-integer-x");e.exports=function toLength(t){var e=n(t);return e<=0?0:e>9007199254740991?9007199254740991:e}}()},{"to-integer-x":12}],2:[function(t,e,n){"use strict";var r=t("object-keys"),o=t("foreach"),i="function"==typeof Symbol&&"symbol"==typeof Symbol(),u=Object.prototype.toString,c=function(t){return"function"==typeof t&&"[object Function]"===u.call(t)},f=Object.defineProperty&&function(){var t={};try{Object.defineProperty(t,"x",{enumerable:!1,value:t});for(var e in t)return!1;return t.x===t}catch(t){return!1}}(),s=function(t,e,n,r){(!(e in t)||c(r)&&r())&&(f?Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n,writable:!0}):t[e]=n)},a=function(t,e){var n=arguments.length>2?arguments[2]:{},u=r(e);i&&(u=u.concat(Object.getOwnPropertySymbols(e))),o(u,function(r){s(t,r,e[r],n[r])})};a.supportsDescriptors=!!f,e.exports=a},{foreach:3,"object-keys":10}],3:[function(t,e,n){var r=Object.prototype.hasOwnProperty,o=Object.prototype.toString;e.exports=function forEach(t,e,n){if("[object Function]"!==o.call(e))throw new TypeError("iterator must be a function");var i=t.length;if(i===+i)for(var u=0;u<i;u++)e.call(n,t[u],u,t);else for(var c in t)r.call(t,c)&&e.call(n,t[c],c,t)}},{}],4:[function(t,e,n){!function(){"use strict";var n,r=t("is-nan");if("function"==typeof Number.isFinite)try{Number.isFinite(9007199254740991)&&!Number.isFinite(1/0)&&(n=Number.isFinite)}catch(t){}e.exports=n||function isFinite(t){return!("number"!=typeof t||r(t)||t===1/0||t===-(1/0))}}()},{"is-nan":6}],5:[function(t,e,n){"use strict";e.exports=function isNaN(t){return t!==t}},{}],6:[function(t,e,n){"use strict";var r=t("define-properties"),o=t("./implementation");r(o,{getPolyfill:t("./polyfill"),implementation:o,shim:t("./shim")}),e.exports=o},{"./implementation":5,"./polyfill":7,"./shim":8,"define-properties":2}],7:[function(t,e,n){"use strict";var r=t("./implementation");e.exports=function getPolyfill(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:r}},{"./implementation":5}],8:[function(t,e,n){"use strict";var r=t("define-properties"),o=t("./polyfill");e.exports=function shimNumberIsNaN(){var t=o();return r(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}},{"./polyfill":7,"define-properties":2}],9:[function(t,e,n){!function(){"use strict";var n,r=t("is-nan");if("function"==typeof Math.sign)try{1===Math.sign(10)&&Math.sign(-10)===-1&&0===Math.sign(0)&&(n=Math.sign)}catch(t){}e.exports=n||function sign(t){var e=Number(t);return 0===e||r(e)?e:e>0?1:-1}}()},{"is-nan":6}],10:[function(t,e,n){"use strict";var r=Object.prototype.hasOwnProperty,o=Object.prototype.toString,i=Array.prototype.slice,u=t("./isArguments"),c=Object.prototype.propertyIsEnumerable,f=!c.call({toString:null},"toString"),s=c.call(function(){},"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(t){var e=t.constructor;return e&&e.prototype===t},p={$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},y=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!p["$"+t]&&r.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{l(window[t])}catch(t){return!0}}catch(t){return!0}return!1}(),b=function(t){if("undefined"==typeof window||!y)return l(t);try{return l(t)}catch(t){return!1}},m=function keys(t){var e=null!==t&&"object"==typeof t,n="[object Function]"===o.call(t),i=u(t),c=e&&"[object String]"===o.call(t),l=[];if(!e&&!n&&!i)throw new TypeError("Object.keys called on a non-object");var p=s&&n;if(c&&t.length>0&&!r.call(t,0))for(var y=0;y<t.length;++y)l.push(String(y));if(i&&t.length>0)for(var m=0;m<t.length;++m)l.push(String(m));else for(var h in t)p&&"prototype"===h||!r.call(t,h)||l.push(String(h));if(f)for(var g=b(t),d=0;d<a.length;++d)g&&"constructor"===a[d]||!r.call(t,a[d])||l.push(a[d]);return l};m.shim=function shimObjectKeys(){if(Object.keys){if(!function(){return 2===(Object.keys(arguments)||"").length}(1,2)){var t=Object.keys;Object.keys=function keys(e){return t(u(e)?i.call(e):e)}}}else Object.keys=m;return Object.keys||m},e.exports=m},{"./isArguments":11}],11:[function(t,e,n){"use strict";var r=Object.prototype.toString;e.exports=function isArguments(t){var e=r.call(t),n="[object Arguments]"===e;return n||(n="[object Array]"!==e&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===r.call(t.callee)),n}},{}],12:[function(t,e,n){!function(){"use strict";var n=t("is-nan"),r=t("is-finite-x"),o=t("math-sign-x");e.exports=function toInteger(t){var e=Number(t);return n(e)?0:0!==e&&r(e)?o(e)*Math.floor(Math.abs(e)):e}}()},{"is-finite-x":4,"is-nan":6,"math-sign-x":9}]},{},[1])(1)}); | ||
//# sourceMappingURL=lib/to-length-x.map |
{ | ||
"name": "to-length-x", | ||
"version": "1.1.0", | ||
"description": "toLength module.", | ||
"version": "1.1.1", | ||
"description": "ToLength converts argument to an integer suitable for use as the length of an array-like object.", | ||
"homepage": "https://github.com/Xotic750/to-length-x", | ||
@@ -32,29 +32,35 @@ "author": { | ||
"dependencies": { | ||
"to-integer-x": "^1.1.1" | ||
"to-integer-x": "^1.1.3" | ||
}, | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^11.0.0", | ||
"browserify": "^14.1.0", | ||
"browserify-derequire": "^0.9.4", | ||
"es5-shim": "^4.5.9", | ||
"es6-shim": "^0.35.3", | ||
"es7-shim": "^6.0.0", | ||
"eslint": "^3.15.0", | ||
"eslint": "^3.18.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"json3": "^3.3.2", | ||
"jscs": "^3.0.7", | ||
"uglify-js": "^2.7.5", | ||
"browserify": "^14.1.0", | ||
"browserify-derequire": "^0.9.4", | ||
"jasmine-node": "^1.14.5", | ||
"jsdoc-to-markdown": "^3.0.0", | ||
"nsp": "^2.6.2" | ||
"json3": "^3.3.2", | ||
"make-jasmine-spec-runner-html": "^1.0.4", | ||
"nodemon": "^1.11.0", | ||
"nsp": "^2.6.3", | ||
"replace-x": "^1.0.0", | ||
"uglify-js": "^2.8.16" | ||
}, | ||
"scripts": { | ||
"build": "npm run build:setver && npm run security && npm run eslint && npm run browserify && npm run uglify && npm run docs && npm run build:jasmine && npm test", | ||
"build:jasmine": "make-jasmine-spec-runner-html", | ||
"build:setver": "PKG_VER=$(node -p -e \"require('./package.json').version\") && replace-x \" @version .*\" \" @version ${PKG_VER}\" index.js", | ||
"build:watch": "nodemon --watch index.js --watch package.json --exec 'npm run build'", | ||
"docs": "jsdoc2md --name-format --example-lang js index.js > README.md", | ||
"eslint": "eslint *.js tests/spec/*.js", | ||
"security": "nsp check", | ||
"test": "jasmine-node --matchall tests/spec/", | ||
"security": "nsp check", | ||
"style": "jscs index.js", | ||
"eslint": "eslint *.js tests/spec/*.js", | ||
"docs": "jsdoc2md --name-format --example-lang js index.js > README.md", | ||
"build": "browserify -p browserify-derequire -e index.js -o lib/to-length-x.js -u 'crypto' -s returnExports", | ||
"build-uglify": "uglifyjs lib/to-length-x.js -o lib/to-length-x.min.js --compress --keep-fnames --mangle --beautify ascii_only=true,beautify=false --source-map lib/to-length-x.map" | ||
"test:watch": "nodemon --watch tests/spec/test.js --exec 'npm test'", | ||
"browserify": "browserify -p browserify-derequire -e index.js -o lib/to-length-x.js -u 'crypto' -s returnExports", | ||
"uglify": "uglifyjs lib/to-length-x.js -o lib/to-length-x.min.js --compress --keep-fnames --mangle --beautify ascii_only=true,beautify=false --source-map lib/to-length-x.map" | ||
} | ||
} |
@@ -26,23 +26,9 @@ <a name="module_to-length-x"></a> | ||
toLength module. | ||
ToLength converts argument to an integer suitable for use as the length of an array-like object. | ||
<h2>ECMAScript compatibility shims for legacy JavaScript engines</h2> | ||
`es5-shim.js` monkey-patches a JavaScript context to contain all EcmaScript 5 | ||
methods that can be faithfully emulated with a legacy JavaScript engine. | ||
Requires ES3 or above. | ||
`es5-sham.js` monkey-patches other ES5 methods as closely as possible. | ||
For these methods, as closely as possible to ES5 is not very close. | ||
Many of these shams are intended only to allow code to be written to ES5 | ||
without causing run-time errors in older engines. In many cases, | ||
this means that these shams cause many ES5 methods to silently fail. | ||
Decide carefully whether this is what you want. Note: es5-sham.js requires | ||
es5-shim.js to be able to work properly. | ||
`json3.js` monkey-patches the EcmaScript 5 JSON implimentation faithfully. | ||
`es6.shim.js` provides compatibility shims so that legacy JavaScript engines | ||
behave as closely as possible to ECMAScript 6 (Harmony). | ||
**Version**: 1.1.0 | ||
**Author:** Xotic750 <Xotic750@gmail.com> | ||
**See**: [7.1.15 ToLength ( argument )](http://www.ecma-international.org/ecma-262/6.0/#sec-tolength) | ||
**Version**: 1.1.1 | ||
**Author**: Xotic750 <Xotic750@gmail.com> | ||
**License**: [MIT](<https://opensource.org/licenses/MIT>) | ||
@@ -49,0 +35,0 @@ **Copyright**: Xotic750 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
731
44655
16
13
56
1
Updatedto-integer-x@^1.1.3