math-sign-x
Advanced tools
Comparing version 1.1.0 to 1.2.0
{ | ||
"root": true, | ||
"extends": "@ljharb", | ||
"plugins": [ | ||
"import" | ||
], | ||
"rules": { | ||
"indent": ["error", 2, { | ||
"SwitchCase": 1 | ||
}], | ||
"global-require": 0, | ||
"max-params": 0, | ||
"block-scoped-var": 1 | ||
} | ||
} | ||
"extends": [ | ||
"@xotic750/eslint-config-standard-x" | ||
] | ||
} |
80
index.js
@@ -31,3 +31,3 @@ /** | ||
* | ||
* @version 1.1.0 | ||
* @version 1.2.0 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
@@ -39,48 +39,42 @@ * @copyright Xotic750 | ||
/* eslint strict: 1 */ | ||
'use strict'; | ||
/* global module */ | ||
var $isNaN = require('is-nan'); | ||
;(function () { // eslint-disable-line no-extra-semi | ||
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) {} | ||
} | ||
'use strict'; | ||
var $isNaN = require('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. | ||
* @returns {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; | ||
} | ||
/** | ||
* 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; | ||
}; | ||
}()); | ||
return n > 0 ? 1 : -1; | ||
}; |
@@ -32,3 +32,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.1.0 | ||
* @version 1.2.0 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
@@ -40,49 +40,43 @@ * @copyright Xotic750 | ||
/* eslint strict: 1 */ | ||
'use strict'; | ||
/* global module */ | ||
var $isNaN = _dereq_('is-nan'); | ||
;(function () { // eslint-disable-line no-extra-semi | ||
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) {} | ||
} | ||
'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. | ||
* @returns {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; | ||
} | ||
/** | ||
* 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; | ||
}; | ||
}()); | ||
return n > 0 ? 1 : -1; | ||
}; | ||
@@ -89,0 +83,0 @@ },{"is-nan":5}],2:[function(_dereq_,module,exports){ |
@@ -1,2 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.returnExports=e()}}(function(){return function e(t,r,n){function s(i,c){if(!r[i]){if(!t[i]){var u="function"==typeof require&&require;if(!c&&u)return u(i,!0);if(o)return o(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var l=r[i]={exports:{}};t[i][0].call(l.exports,function(e){var r=t[i][1][e];return s(r?r:e)},l,l.exports,e,t,r,n)}return r[i].exports}for(var o="function"==typeof require&&require,i=0;i<n.length;i++)s(n[i]);return s}({1:[function(e,t,r){!function(){"use strict";var r,n=e("is-nan");if("function"==typeof Math.sign)try{1===Math.sign(10)&&Math.sign(-10)===-1&&0===Math.sign(0)&&(r=Math.sign)}catch(e){}t.exports=r||function sign(e){var t=Number(e);return 0===t||n(t)?t:t>0?1:-1}}()},{"is-nan":5}],2:[function(e,t,r){"use strict";var n=e("object-keys"),o=e("foreach"),i="function"==typeof Symbol&&"symbol"==typeof Symbol(),c=Object.prototype.toString,u=function(e){return"function"==typeof e&&"[object Function]"===c.call(e)},f=Object.defineProperty&&function(){var e={};try{Object.defineProperty(e,"x",{enumerable:!1,value:e});for(var t in e)return!1;return e.x===e}catch(e){return!1}}(),l=function(e,t,r,n){(!(t in e)||u(n)&&n())&&(f?Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:r,writable:!0}):e[t]=r)},s=function(e,t){var r=arguments.length>2?arguments[2]:{},c=n(t);i&&(c=c.concat(Object.getOwnPropertySymbols(t))),o(c,function(n){l(e,n,t[n],r[n])})};s.supportsDescriptors=!!f,t.exports=s},{foreach:3,"object-keys":8}],3:[function(e,t,r){var n=Object.prototype.hasOwnProperty,o=Object.prototype.toString;t.exports=function forEach(e,t,r){if("[object Function]"!==o.call(t))throw new TypeError("iterator must be a function");var i=e.length;if(i===+i)for(var c=0;c<i;c++)t.call(r,e[c],c,e);else for(var u in e)n.call(e,u)&&t.call(r,e[u],u,e)}},{}],4:[function(e,t,r){"use strict";t.exports=function isNaN(e){return e!==e}},{}],5:[function(e,t,r){"use strict";var n=e("define-properties"),o=e("./implementation");n(o,{getPolyfill:e("./polyfill"),implementation:o,shim:e("./shim")}),t.exports=o},{"./implementation":4,"./polyfill":6,"./shim":7,"define-properties":2}],6:[function(e,t,r){"use strict";var n=e("./implementation");t.exports=function getPolyfill(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:n}},{"./implementation":4}],7:[function(e,t,r){"use strict";var n=e("define-properties"),o=e("./polyfill");t.exports=function shimNumberIsNaN(){var e=o();return n(Number,{isNaN:e},{isNaN:function(){return Number.isNaN!==e}}),e}},{"./polyfill":6,"define-properties":2}],8:[function(e,t,r){"use strict";var n=Object.prototype.hasOwnProperty,o=Object.prototype.toString,i=Array.prototype.slice,c=e("./isArguments"),u=Object.prototype.propertyIsEnumerable,f=!u.call({toString:null},"toString"),l=u.call(function(){},"prototype"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=function(e){var t=e.constructor;return t&&t.prototype===e},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 e in window)try{if(!p["$"+e]&&n.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{a(window[e])}catch(e){return!0}}catch(e){return!0}return!1}(),b=function(e){if("undefined"==typeof window||!y)return a(e);try{return a(e)}catch(e){return!1}},m=function keys(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===o.call(e),i=c(e),u=t&&"[object String]"===o.call(e),a=[];if(!t&&!r&&!i)throw new TypeError("Object.keys called on a non-object");var p=l&&r;if(u&&e.length>0&&!n.call(e,0))for(var y=0;y<e.length;++y)a.push(String(y));if(i&&e.length>0)for(var m=0;m<e.length;++m)a.push(String(m));else for(var h in e)p&&"prototype"===h||!n.call(e,h)||a.push(String(h));if(f)for(var g=b(e),d=0;d<s.length;++d)g&&"constructor"===s[d]||!n.call(e,s[d])||a.push(s[d]);return a};m.shim=function shimObjectKeys(){if(Object.keys){if(!function(){return 2===(Object.keys(arguments)||"").length}(1,2)){var e=Object.keys;Object.keys=function keys(t){return e(c(t)?i.call(t):t)}}}else Object.keys=m;return Object.keys||m},t.exports=m},{"./isArguments":9}],9:[function(e,t,r){"use strict";var n=Object.prototype.toString;t.exports=function isArguments(e){var t=n.call(e),r="[object Arguments]"===t;return r||(r="[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===n.call(e.callee)),r}},{}]},{},[1])(1)}); | ||
//# sourceMappingURL=lib/math-sign-x.map | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).returnExports=e()}}(function(){return function e(t,r,n){function s(i,c){if(!r[i]){if(!t[i]){var u="function"==typeof require&&require;if(!c&&u)return u(i,!0);if(o)return o(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var l=r[i]={exports:{}};t[i][0].call(l.exports,function(e){var r=t[i][1][e];return s(r||e)},l,l.exports,e,t,r,n)}return r[i].exports}for(var o="function"==typeof require&&require,i=0;i<n.length;i++)s(n[i]);return s}({1:[function(e,t,r){"use strict";var n,o=e("is-nan");if("function"==typeof Math.sign)try{1===Math.sign(10)&&-1===Math.sign(-10)&&0===Math.sign(0)&&(n=Math.sign)}catch(e){}t.exports=n||function sign(e){var t=Number(e);return 0===t||o(t)?t:t>0?1:-1}},{"is-nan":5}],2:[function(e,t,r){"use strict";var n=e("object-keys"),o=e("foreach"),i="function"==typeof Symbol&&"symbol"==typeof Symbol(),c=Object.prototype.toString,u=function(e){return"function"==typeof e&&"[object Function]"===c.call(e)},f=Object.defineProperty&&function(){var e={};try{Object.defineProperty(e,"x",{enumerable:!1,value:e});for(var t in e)return!1;return e.x===e}catch(e){return!1}}(),l=function(e,t,r,n){(!(t in e)||u(n)&&n())&&(f?Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:r,writable:!0}):e[t]=r)},s=function(e,t){var r=arguments.length>2?arguments[2]:{},c=n(t);i&&(c=c.concat(Object.getOwnPropertySymbols(t))),o(c,function(n){l(e,n,t[n],r[n])})};s.supportsDescriptors=!!f,t.exports=s},{foreach:3,"object-keys":8}],3:[function(e,t,r){var n=Object.prototype.hasOwnProperty,o=Object.prototype.toString;t.exports=function forEach(e,t,r){if("[object Function]"!==o.call(t))throw new TypeError("iterator must be a function");var i=e.length;if(i===+i)for(var c=0;c<i;c++)t.call(r,e[c],c,e);else for(var u in e)n.call(e,u)&&t.call(r,e[u],u,e)}},{}],4:[function(e,t,r){"use strict";t.exports=function isNaN(e){return e!==e}},{}],5:[function(e,t,r){"use strict";var n=e("define-properties"),o=e("./implementation");n(o,{getPolyfill:e("./polyfill"),implementation:o,shim:e("./shim")}),t.exports=o},{"./implementation":4,"./polyfill":6,"./shim":7,"define-properties":2}],6:[function(e,t,r){"use strict";var n=e("./implementation");t.exports=function getPolyfill(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:n}},{"./implementation":4}],7:[function(e,t,r){"use strict";var n=e("define-properties"),o=e("./polyfill");t.exports=function shimNumberIsNaN(){var e=o();return n(Number,{isNaN:e},{isNaN:function(){return Number.isNaN!==e}}),e}},{"./polyfill":6,"define-properties":2}],8:[function(e,t,r){"use strict";var n=Object.prototype.hasOwnProperty,o=Object.prototype.toString,i=Array.prototype.slice,c=e("./isArguments"),u=Object.prototype.propertyIsEnumerable,f=!u.call({toString:null},"toString"),l=u.call(function(){},"prototype"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=function(e){var t=e.constructor;return t&&t.prototype===e},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 e in window)try{if(!p["$"+e]&&n.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{a(window[e])}catch(e){return!0}}catch(e){return!0}return!1}(),b=function(e){if("undefined"==typeof window||!y)return a(e);try{return a(e)}catch(e){return!1}},m=function keys(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===o.call(e),i=c(e),u=t&&"[object String]"===o.call(e),a=[];if(!t&&!r&&!i)throw new TypeError("Object.keys called on a non-object");var p=l&&r;if(u&&e.length>0&&!n.call(e,0))for(var y=0;y<e.length;++y)a.push(String(y));if(i&&e.length>0)for(var m=0;m<e.length;++m)a.push(String(m));else for(var h in e)p&&"prototype"===h||!n.call(e,h)||a.push(String(h));if(f)for(var g=b(e),d=0;d<s.length;++d)g&&"constructor"===s[d]||!n.call(e,s[d])||a.push(s[d]);return a};m.shim=function shimObjectKeys(){if(Object.keys){if(!function(){return 2===(Object.keys(arguments)||"").length}(1,2)){var e=Object.keys;Object.keys=function keys(t){return e(c(t)?i.call(t):t)}}}else Object.keys=m;return Object.keys||m},t.exports=m},{"./isArguments":9}],9:[function(e,t,r){"use strict";var n=Object.prototype.toString;t.exports=function isArguments(e){var t=n.call(e),r="[object Arguments]"===t;return r||(r="[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===n.call(e.callee)),r}},{}]},{},[1])(1)}); |
{ | ||
"name": "math-sign-x", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "ES6-compliant shim for Math.sign.", | ||
@@ -12,3 +12,4 @@ "homepage": "https://github.com/Xotic750/math-sign-x", | ||
"keywords": [ | ||
"sameValueZero", | ||
"math", | ||
"sign", | ||
"module", | ||
@@ -35,32 +36,48 @@ "javascript", | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^11.0.0", | ||
"browserify": "^14.1.0", | ||
"@xotic750/eslint-config-standard-x": "^1.4.0", | ||
"browserify": "^14.4.0", | ||
"browserify-derequire": "^0.9.4", | ||
"cross-env": "^5.0.1", | ||
"es5-shim": "^4.5.9", | ||
"es6-shim": "^0.35.3", | ||
"es7-shim": "^6.0.0", | ||
"eslint": "^3.18.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint": "^4.1.1", | ||
"eslint-plugin-compat": "^1.0.4", | ||
"eslint-plugin-css-modules": "^2.7.2", | ||
"eslint-plugin-eslint-comments": "^1.0.2", | ||
"eslint-plugin-jsdoc": "^3.1.1", | ||
"eslint-plugin-json": "^1.2.0", | ||
"eslint-plugin-no-use-extend-native": "^0.3.12", | ||
"husky": "^0.13.4", | ||
"jasmine-node": "^1.14.5", | ||
"jsdoc-to-markdown": "^3.0.0", | ||
"json3": "^3.3.2", | ||
"make-jasmine-spec-runner-html": "^1.1.0", | ||
"make-jasmine-spec-runner-html": "^1.2.0", | ||
"nodemon": "^1.11.0", | ||
"nsp": "^2.6.3", | ||
"replace-x": "^1.1.1", | ||
"uglify-js": "^2.8.16" | ||
"parallelshell": "^3.0.1", | ||
"replace-x": "^1.3.1", | ||
"rimraf": "^2.6.1", | ||
"serve": "^6.0.0", | ||
"uglify-js": "^3.0.23" | ||
}, | ||
"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", | ||
"clean": "rimraf README.md lib/*", | ||
"clean:jasmine": "rimraf tests/index.html tests/run.js", | ||
"clean:all": "npm run clean:jasmine && npm run clean", | ||
"build": "npm run clean && npm run lint && npm run browserify && npm run uglify && npm run docs && npm test && npm run security", | ||
"build:jasmine": "npm run clean: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'", | ||
"production": "npm run clean:all && npm run build:jasmine && npm run build:setver && npm run build", | ||
"start": "parallelshell \"serve\" \"nodemon --watch index.js --exec 'npm run build'\"", | ||
"docs": "jsdoc2md --name-format --example-lang js index.js > README.md", | ||
"eslint": "eslint *.js tests/spec/*.js", | ||
"lint": "eslint *.js tests/spec/*.js", | ||
"lint-fix": "eslint --fix *.js tests/spec/*.js", | ||
"security": "nsp check", | ||
"test": "jasmine-node --matchall tests/spec/", | ||
"test:watch": "nodemon --watch tests/spec/test.js --exec 'npm test'", | ||
"browserify": "browserify -p browserify-derequire -e index.js -o lib/math-sign-x.js -u 'crypto' -s returnExports", | ||
"uglify": "uglifyjs lib/math-sign-x.js -o lib/math-sign-x.min.js --compress --keep-fnames --mangle --beautify ascii_only=true,beautify=false --source-map lib/math-sign-x.map" | ||
"uglify": "uglifyjs lib/math-sign-x.js -o lib/math-sign-x.min.js --support-ie8 --compress --keep-fnames --mangle --beautify ascii_only=true,beautify=false --source-map filename=lib/math-sign-x.map", | ||
"precommit": "npm run production", | ||
"prepush": "npm run production" | ||
} | ||
} |
@@ -31,3 +31,3 @@ <a name="module_math-sign-x"></a> | ||
**See**: [20.2.2.29 Math.sign(x)](http://www.ecma-international.org/ecma-262/6.0/#sec-math.sign) | ||
**Version**: 1.1.0 | ||
**Version**: 1.2.0 | ||
**Author**: Xotic750 <Xotic750@gmail.com> | ||
@@ -34,0 +34,0 @@ **License**: [MIT](<https://opensource.org/licenses/MIT>) |
@@ -1,81 +0,73 @@ | ||
/* eslint strict: 1, max-lines: 1, symbol-description: 1, max-nested-callbacks: 1, | ||
max-statements: 1, no-magic-numbers: 1, id-length: 1 */ | ||
'use strict'; | ||
/* global JSON:true, expect, module, require, describe, it, xit, returnExports */ | ||
var mathSign; | ||
if (typeof module === 'object' && module.exports) { | ||
require('es5-shim'); | ||
require('es5-shim/es5-sham'); | ||
if (typeof JSON === 'undefined') { | ||
JSON = {}; | ||
} | ||
require('json3').runInContext(null, JSON); | ||
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(); | ||
} | ||
}); | ||
mathSign = require('../../index.js'); | ||
} else { | ||
mathSign = returnExports; | ||
} | ||
;(function () { // eslint-disable-line no-extra-semi | ||
var ifFunctionsHaveNamesIt = function foo() {}.name === 'foo' ? it : xit; | ||
'use strict'; | ||
var isPositiveZero = function (zero) { | ||
return zero === 0 && 1 / zero === Infinity; | ||
}; | ||
var mathSign; | ||
if (typeof module === 'object' && module.exports) { | ||
require('es5-shim'); | ||
require('es5-shim/es5-sham'); | ||
if (typeof JSON === 'undefined') { | ||
JSON = {}; | ||
} | ||
require('json3').runInContext(null, JSON); | ||
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(); | ||
} | ||
}); | ||
mathSign = require('../../index.js'); | ||
} else { | ||
mathSign = returnExports; | ||
} | ||
var isNegativeZero = function (zero) { | ||
return zero === 0 && 1 / zero === -Infinity; | ||
}; | ||
var ifFunctionsHaveNamesIt = function foo() {}.name === 'foo' ? it : xit; | ||
var numberIsNaN = function (value) { | ||
return value !== value; | ||
}; | ||
var isPositiveZero = function (zero) { | ||
return zero === 0 && 1 / zero === Infinity; | ||
}; | ||
describe('mathSign', function () { | ||
ifFunctionsHaveNamesIt('has the right name', function () { | ||
expect(mathSign.name).toBe('sign'); | ||
}); | ||
var isNegativeZero = function (zero) { | ||
return zero === 0 && 1 / zero === -Infinity; | ||
}; | ||
it('has the right arity', function () { | ||
expect(mathSign.length).toBe(1); | ||
}); | ||
var numberIsNaN = function (value) { | ||
return value !== value; | ||
}; | ||
describe('mathSign', function () { | ||
ifFunctionsHaveNamesIt('has the right name', function () { | ||
expect(mathSign.name).toBe('sign'); | ||
it('should be correct', function () { | ||
// we also verify that [[ToNumber]] is being called | ||
[Infinity, 1].forEach(function (value) { | ||
expect(mathSign(value)).toBe(1); | ||
expect(mathSign(String(value))).toBe(1); | ||
}); | ||
expect(mathSign(true)).toBe(1); | ||
it('has the right arity', function () { | ||
expect(mathSign.length).toBe(1); | ||
[-Infinity, -1].forEach(function (value) { | ||
expect(mathSign(value)).toBe(-1); | ||
expect(mathSign(String(value))).toBe(-1); | ||
}); | ||
it('should be correct', function () { | ||
// we also verify that [[ToNumber]] is being called | ||
[Infinity, 1].forEach(function (value) { | ||
expect(mathSign(value)).toBe(1); | ||
expect(mathSign(String(value))).toBe(1); | ||
}); | ||
expect(mathSign(true)).toBe(1); | ||
[-Infinity, -1].forEach(function (value) { | ||
expect(mathSign(value)).toBe(-1); | ||
expect(mathSign(String(value))).toBe(-1); | ||
}); | ||
expect(isPositiveZero(mathSign(+0))).toBe(true); | ||
expect(isPositiveZero(mathSign('0'))).toBe(true); | ||
expect(isPositiveZero(mathSign('+0'))).toBe(true); | ||
expect(isPositiveZero(mathSign(''))).toBe(true); | ||
expect(isPositiveZero(mathSign(' '))).toBe(true); | ||
expect(isPositiveZero(mathSign(null))).toBe(true); | ||
expect(isPositiveZero(mathSign(false))).toBe(true); | ||
expect(isNegativeZero(mathSign(-0))).toBe(true); | ||
expect(isNegativeZero(mathSign('-0'))).toBe(true); | ||
expect(numberIsNaN(mathSign(NaN))).toBe(true); | ||
expect(numberIsNaN(mathSign('NaN'))).toBe(true); | ||
expect(numberIsNaN(mathSign(undefined))).toBe(true); | ||
}); | ||
expect(isPositiveZero(mathSign(+0))).toBe(true); | ||
expect(isPositiveZero(mathSign('0'))).toBe(true); | ||
expect(isPositiveZero(mathSign('+0'))).toBe(true); | ||
expect(isPositiveZero(mathSign(''))).toBe(true); | ||
expect(isPositiveZero(mathSign(' '))).toBe(true); | ||
expect(isPositiveZero(mathSign(null))).toBe(true); | ||
expect(isPositiveZero(mathSign(false))).toBe(true); | ||
expect(isNegativeZero(mathSign(-0))).toBe(true); | ||
expect(isNegativeZero(mathSign('-0'))).toBe(true); | ||
expect(numberIsNaN(mathSign(NaN))).toBe(true); | ||
expect(numberIsNaN(mathSign('NaN'))).toBe(true); | ||
expect(numberIsNaN(mathSign(undefined))).toBe(true); | ||
}); | ||
}()); | ||
}); |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1
4
38884
26
15
496