to-length-x
Advanced tools
Comparing version 1.0.5 to 1.1.0
26
index.js
@@ -44,3 +44,3 @@ /** | ||
* | ||
* @version 1.0.5 | ||
* @version 1.1.0 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
@@ -52,13 +52,16 @@ * @copyright Xotic750 | ||
/*jslint maxlen:80, es6:true, white:true */ | ||
/* 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:true, esnext:true, plusplus:true, maxparams:1, maxdepth:1, | ||
maxstatements:6, maxcomplexity:3 */ | ||
/* 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 */ | ||
/*global require, module */ | ||
/* eslint strict: 1, max-statements: 1 */ | ||
;(function () { | ||
/* global require, module */ | ||
;(function () { // eslint-disable-line no-extra-semi | ||
'use strict'; | ||
@@ -68,2 +71,3 @@ | ||
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER; | ||
var zero = 0; | ||
@@ -85,4 +89,4 @@ /** | ||
var len = toInteger(value); | ||
if (len <= 0) { | ||
return 0; | ||
if (len <= zero) { | ||
return zero; | ||
} // includes converting -0 to +0 | ||
@@ -89,0 +93,0 @@ if (len > MAX_SAFE_INTEGER) { |
@@ -45,3 +45,3 @@ (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){ | ||
* | ||
* @version 1.0.5 | ||
* @version 1.1.0 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
@@ -53,13 +53,16 @@ * @copyright Xotic750 | ||
/*jslint maxlen:80, es6:true, white:true */ | ||
/* 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:true, esnext:true, plusplus:true, maxparams:1, maxdepth:1, | ||
maxstatements:6, maxcomplexity:3 */ | ||
/* 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 */ | ||
/*global require, module */ | ||
/* eslint strict: 1, max-statements: 1 */ | ||
;(function () { | ||
/* global require, module */ | ||
;(function () { // eslint-disable-line no-extra-semi | ||
'use strict'; | ||
@@ -69,2 +72,3 @@ | ||
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER; | ||
var zero = 0; | ||
@@ -86,4 +90,4 @@ /** | ||
var len = toInteger(value); | ||
if (len <= 0) { | ||
return 0; | ||
if (len <= zero) { | ||
return zero; | ||
} // includes converting -0 to +0 | ||
@@ -141,3 +145,3 @@ if (len > MAX_SAFE_INTEGER) { | ||
* | ||
* @version 1.0.6 | ||
* @version 1.1.1 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
@@ -149,13 +153,16 @@ * @copyright Xotic750 | ||
/*jslint maxlen:80, es6:true, white:true */ | ||
/* 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:true, esnext:true, plusplus:true, maxparams:1, maxdepth:1, | ||
maxstatements:7, maxcomplexity:4 */ | ||
/* 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 */ | ||
/*global module */ | ||
/* eslint strict: 1, max-statements: 1 */ | ||
;(function () { | ||
/* global module */ | ||
;(function () { // eslint-disable-line no-extra-semi | ||
'use strict'; | ||
@@ -169,2 +176,3 @@ | ||
var $abs = Math.abs; | ||
var zero = 0; | ||
@@ -186,5 +194,5 @@ /** | ||
if ($isNaN(number)) { | ||
return 0; | ||
return zero; | ||
} | ||
if (number === 0 || !$isFinite(number)) { | ||
if (number === zero || !$isFinite(number)) { | ||
return number; | ||
@@ -191,0 +199,0 @@ } |
@@ -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;n.exports=function toLength(e){var n=t(e);return 0>=n?0: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;n.exports=function toInteger(n){var u=e(n);return t(u)?0:0!==u&&r(u)?o(u)*i(f(u)):u}}()},{}]},{},[1])(1)}); | ||
!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)}); | ||
//# sourceMappingURL=lib/to-length-x.map |
{ | ||
"name": "to-length-x", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "toLength module.", | ||
@@ -32,15 +32,19 @@ "homepage": "https://github.com/Xotic750/to-length-x", | ||
"dependencies": { | ||
"to-integer-x": "^1.0.6" | ||
"to-integer-x": "^1.1.1" | ||
}, | ||
"devDependencies": { | ||
"es5-shim": "^4.5.4", | ||
"es6-shim": "^0.34.4", | ||
"@ljharb/eslint-config": "^11.0.0", | ||
"es5-shim": "^4.5.9", | ||
"es6-shim": "^0.35.3", | ||
"es7-shim": "^6.0.0", | ||
"eslint": "^3.15.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"json3": "^3.3.2", | ||
"jscs": "^2.9.0", | ||
"uglify-js": "^2.6.1", | ||
"browserify": "^13.0.0", | ||
"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": "^1.3.3", | ||
"nsp": "^2.2.0" | ||
"jsdoc-to-markdown": "^3.0.0", | ||
"nsp": "^2.6.2" | ||
}, | ||
@@ -51,2 +55,3 @@ "scripts": { | ||
"style": "jscs index.js", | ||
"eslint": "eslint *.js tests/spec/*.js", | ||
"docs": "jsdoc2md --name-format --example-lang js index.js > README.md", | ||
@@ -53,0 +58,0 @@ "build": "browserify -p browserify-derequire -e index.js -o lib/to-length-x.js -u 'crypto' -s returnExports", |
<a name="module_to-length-x"></a> | ||
## to-length-x | ||
@@ -44,3 +45,3 @@ <a href="https://travis-ci.org/Xotic750/to-length-x" | ||
**Version**: 1.0.5 | ||
**Version**: 1.1.0 | ||
**Author:** Xotic750 <Xotic750@gmail.com> | ||
@@ -50,2 +51,3 @@ **License**: [MIT](<https://opensource.org/licenses/MIT>) | ||
<a name="exp_module_to-length-x--module.exports"></a> | ||
### `module.exports(value)` ⇒ <code>number</code> ⏏ | ||
@@ -52,0 +54,0 @@ Converts `value` to an integer suitable for use as the length of an |
@@ -1,12 +0,16 @@ | ||
/*jslint maxlen:80, es6:true, white:true */ | ||
/* 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:true, esnext:true, plusplus:true, maxparams:1, maxdepth:2, | ||
maxstatements:11, maxcomplexity:3 */ | ||
/* 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:2, | ||
maxstatements:12, maxcomplexity:4 */ | ||
/*global JSON:true, expect, module, require, describe, it, returnExports */ | ||
/* eslint strict: 1, max-lines: 1, symbol-description: 1, max-nested-callbacks: 1, | ||
max-statements: 1 */ | ||
(function () { | ||
/* global JSON:true, expect, module, require, describe, it, returnExports */ | ||
(function () { // eslint-disable-line no-extra-semi | ||
'use strict'; | ||
@@ -23,2 +27,9 @@ | ||
require('es6-shim'); | ||
var es7 = require('es7-shim'); | ||
Object.keys(es7).forEach(function (key) { | ||
var obj = es7[key]; | ||
if (typeof obj.shim === 'function') { | ||
obj.shim(); | ||
} | ||
}); | ||
toLength = require('../../index.js'); | ||
@@ -32,14 +43,14 @@ } else { | ||
var coercibleObject = { | ||
toString: function () { | ||
return 42; | ||
}, | ||
valueOf: function () { | ||
return 3; | ||
}, | ||
toString: function () { | ||
return 42; | ||
} | ||
}; | ||
var uncoercibleObject = { | ||
valueOf: function () { | ||
toString: function () { | ||
return {}; | ||
}, | ||
toString: function () { | ||
valueOf: function () { | ||
return {}; | ||
@@ -55,11 +66,8 @@ } | ||
[-0, -1, -42, -Infinity].forEach(function (negative) { | ||
expect(Object.is(0, toLength(negative))) | ||
.toBe(true, negative + ' coerces to +0'); | ||
expect(Object.is(0, toLength(negative))).toBe(true, negative + ' coerces to +0'); | ||
}); | ||
expect(toLength(Number.MAX_SAFE_INTEGER + 1)) | ||
.toBe(Number.MAX_SAFE_INTEGER, '2^53 coerces to 2^53 - 1'); | ||
expect(toLength(Number.MAX_SAFE_INTEGER + 3)) | ||
.toBe(Number.MAX_SAFE_INTEGER, '2^53 + 2 coerces to 2^53 - 1'); | ||
expect(toLength(Number.MAX_SAFE_INTEGER + 1)).toBe(Number.MAX_SAFE_INTEGER, '2^53 coerces to 2^53 - 1'); | ||
expect(toLength(Number.MAX_SAFE_INTEGER + 3)).toBe(Number.MAX_SAFE_INTEGER, '2^53 + 2 coerces to 2^53 - 1'); | ||
}); | ||
}); | ||
}()); |
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
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
130141
14
483
70
14
Updatedto-integer-x@^1.1.1