parse-json-bignumber
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -224,40 +224,3 @@ "use strict"; | ||
function checkIsBigNumber(some) { | ||
var methods = [ | ||
"absoluteValue", "abs", | ||
"comparedTo", | ||
"decimalPlaces", "dp", | ||
"dividedBy", "div", | ||
"dividedToIntegerBy", "idiv", | ||
"exponentiatedBy", "pow", | ||
"integerValue", | ||
"isEqualTo", "eq", | ||
"isFinite", | ||
"isGreaterThan", "gt", | ||
"isGreaterThanOrEqualTogte", | ||
"isInteger", | ||
"isLessThan", "lt", | ||
"isLessThanOrEqualTo", "lte", | ||
"isNaN", | ||
"isNegative", | ||
"isPositive", | ||
"isZero", | ||
"minus", | ||
"modulo", "mod", | ||
"multipliedBy", "times", | ||
"negated", | ||
"plus", | ||
"precision", "sd", | ||
"shiftedBy", | ||
"squareRoot", "sqrt", | ||
"toExponential", | ||
"toFixed", | ||
"toFormat", | ||
"toFraction", | ||
"toJSON", | ||
"toNumber", | ||
"toPrecision", | ||
"toString", | ||
"valueOf" | ||
]; | ||
return some && typeof some === 'object' && methods.every(function (m) { return m in some; }); | ||
return some && (options.BigNumber ? some instanceof options.BigNumber || options.BigNumber.isBigNumber(some) : false); | ||
} | ||
@@ -264,0 +227,0 @@ function str(key, holder) { |
@@ -1,1 +0,1 @@ | ||
(function(a,b){if('function'==typeof define&&define.amd)define(['module'],b);else if('undefined'!=typeof exports)b(module);else{var c={exports:{}};b(c),a.parseJsonBignumber=c.exports}})(this,function(a){'use strict';a.exports=function(a){function b(a){return v.lastIndex=0,v.test(a)?'"'+a.replace(v,function(b){var a=u[b];return'string'==typeof a?a:'\\u'+('0000'+b.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function c(a){return a&&'object'==typeof a&&['absoluteValue','abs','comparedTo','decimalPlaces','dp','dividedBy','div','dividedToIntegerBy','idiv','exponentiatedBy','pow','integerValue','isEqualTo','eq','isFinite','isGreaterThan','gt','isGreaterThanOrEqualTogte','isInteger','isLessThan','lt','isLessThanOrEqualTo','lte','isNaN','isNegative','isPositive','isZero','minus','modulo','mod','multipliedBy','times','negated','plus','precision','sd','shiftedBy','squareRoot','sqrt','toExponential','toFixed','toFormat','toFraction','toJSON','toNumber','toPrecision','toString','valueOf'].every(function(b){return b in a})}function d(a,e){var f,g,h,i,j,k=s,l=e[a],m=c(l);switch(m&&!l.isFinite()&&(l=null),l&&'object'==typeof l&&'function'==typeof l.toJSON&&(l=l.toJSON(a)),'function'==typeof w&&(l=w.call(e,a,l)),typeof l){case'string':return m?l:b(l);case'number':return isFinite(l)?l+'':'null';case'boolean':return l+'';case'object':if(!l)return'null';if(s+=t,j=[],'[object Array]'===Object.prototype.toString.apply(l)){for(i=l.length,f=0;f<i;f+=1)j[f]=d(f,l)||'null';return h=0===j.length?'[]':s?'[\n'+s+j.join(',\n'+s)+'\n'+k+']':'['+j.join(',')+']',s=k,h}if(w&&'object'==typeof w)for(i=w.length,f=0;f<i;f+=1)'string'==typeof w[f]&&(g=w[f],h=d(g,l),h&&j.push(b(g)+(s?': ':':')+h));else for(g in l)Object.prototype.hasOwnProperty.call(l,g)&&(h=d(g,l),h&&j.push(b(g)+(s?': ':':')+h));return h=0===j.length?'{}':s?'{\n'+s+j.join(',\n'+s)+'\n'+k+'}':'{'+j.join(',')+'}',s=k,h;}}var e={strict:!1};a!==void 0&&null!==a&&!0===a.strict&&(e.strict=!0);var f,g,h,i,j={'"':'"',"\\":'\\',"/":'/',b:'\b',f:'\f',n:'\n',r:'\r',t:'\t'},k=function(a){throw{name:'SyntaxError',message:a,at:f,text:h}},l=function(a){return a&&a!==g&&k('Expected \''+a+'\' instead of \''+g+'\''),g=h.charAt(f),f+=1,g},m=function(){var a,b='';for('-'===g&&(b='-',l('-'));'0'<=g&&'9'>=g;)b+=g,l();if('.'===g)for(b+='.';l()&&'0'<=g&&'9'>=g;)b+=g;if('e'===g||'E'===g)for(b+=g,l(),('-'===g||'+'===g)&&(b+=g,l());'0'<=g&&'9'>=g;)b+=g,l();return a=+b,isFinite(a)?15<b.length?b:a:void k('Bad number')},n=function(){var a,b,c,d='';if('"'===g)for(;l();){if('"'===g)return l(),d;if('\\'!==g)d+=g;else if(l(),'u'===g){for(c=0,b=0;4>b&&(a=parseInt(l(),16),!!isFinite(a));b+=1)c=16*c+a;d+=String.fromCharCode(c)}else if('string'==typeof j[g])d+=j[g];else break}k('Bad string')},o=function(){for(;g&&' '>=g;)l()},p=function(){switch(g){case't':return l('t'),l('r'),l('u'),l('e'),!0;case'f':return l('f'),l('a'),l('l'),l('s'),l('e'),!1;case'n':return l('n'),l('u'),l('l'),l('l'),null;}k('Unexpected \''+g+'\'')},q=function(){var a=[];if('['===g){if(l('['),o(),']'===g)return l(']'),a;for(;g;){if(a.push(i()),o(),']'===g)return l(']'),a;l(','),o()}}k('Bad array')},r=function(){var a,b={};if('{'===g){if(l('{'),o(),'}'===g)return l('}'),b;for(;g;){if(a=n(),o(),l(':'),!0===e.strict&&Object.hasOwnProperty.call(b,a)&&k('Duplicate key "'+a+'"'),b[a]=i(),o(),'}'===g)return l('}'),b;l(','),o()}}k('Bad object')};i=function(){return o(),'{'===g?r():'['===g?q():'"'===g?n():'-'===g?m():'0'<=g&&'9'>=g?m():p()};var s,t,u,w,v=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,x=function(a,b,c){var e;if(s='',t='','number'==typeof c)for(e=0;e<c;e+=1)t+=' ';else'string'==typeof c&&(t=c);if(w=b,b&&'function'!=typeof b&&('object'!=typeof b||'number'!=typeof b.length))throw new Error('JSON.stringify');return d('',{"":a})},y=function(a,b){var c;return h=a+'',f=0,g=' ',c=i(),o(),g&&k('Syntax error'),'function'==typeof b?function a(c,d){var e,f=c[d];return f&&'object'==typeof f&&Object.keys(f).forEach(function(b){e=a(f,b),void 0===e?delete f[b]:f[b]=e}),b.call(c,d,f)}({"":c},''):c};return{parse:y,stringify:x}}}); | ||
(function(a,b){if('function'==typeof define&&define.amd)define(['module'],b);else if('undefined'!=typeof exports)b(module);else{var c={exports:{}};b(c),a.parseJsonBignumber=c.exports}})(this,function(a){'use strict';a.exports=function(a){function b(a){return v.lastIndex=0,v.test(a)?'"'+a.replace(v,function(b){var a=u[b];return'string'==typeof a?a:'\\u'+('0000'+b.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function c(b){return b&&!!a.BigNumber&&(b instanceof a.BigNumber||a.BigNumber.isBigNumber(b))}function d(a,e){var f,g,h,i,j,k=s,l=e[a],m=c(l);switch(m&&!l.isFinite()&&(l=null),l&&'object'==typeof l&&'function'==typeof l.toJSON&&(l=l.toJSON(a)),'function'==typeof w&&(l=w.call(e,a,l)),typeof l){case'string':return m?l:b(l);case'number':return isFinite(l)?l+'':'null';case'boolean':return l+'';case'object':if(!l)return'null';if(s+=t,j=[],'[object Array]'===Object.prototype.toString.apply(l)){for(i=l.length,f=0;f<i;f+=1)j[f]=d(f,l)||'null';return h=0===j.length?'[]':s?'[\n'+s+j.join(',\n'+s)+'\n'+k+']':'['+j.join(',')+']',s=k,h}if(w&&'object'==typeof w)for(i=w.length,f=0;f<i;f+=1)'string'==typeof w[f]&&(g=w[f],h=d(g,l),h&&j.push(b(g)+(s?': ':':')+h));else for(g in l)Object.prototype.hasOwnProperty.call(l,g)&&(h=d(g,l),h&&j.push(b(g)+(s?': ':':')+h));return h=0===j.length?'{}':s?'{\n'+s+j.join(',\n'+s)+'\n'+k+'}':'{'+j.join(',')+'}',s=k,h;}}var e={strict:!1};a!==void 0&&null!==a&&!0===a.strict&&(e.strict=!0);var f,g,h,i,j={'"':'"',"\\":'\\',"/":'/',b:'\b',f:'\f',n:'\n',r:'\r',t:'\t'},k=function(a){throw{name:'SyntaxError',message:a,at:f,text:h}},l=function(a){return a&&a!==g&&k('Expected \''+a+'\' instead of \''+g+'\''),g=h.charAt(f),f+=1,g},m=function(){var a,b='';for('-'===g&&(b='-',l('-'));'0'<=g&&'9'>=g;)b+=g,l();if('.'===g)for(b+='.';l()&&'0'<=g&&'9'>=g;)b+=g;if('e'===g||'E'===g)for(b+=g,l(),('-'===g||'+'===g)&&(b+=g,l());'0'<=g&&'9'>=g;)b+=g,l();return a=+b,isFinite(a)?15<b.length?b:a:void k('Bad number')},n=function(){var a,b,c,d='';if('"'===g)for(;l();){if('"'===g)return l(),d;if('\\'!==g)d+=g;else if(l(),'u'===g){for(c=0,b=0;4>b&&(a=parseInt(l(),16),!!isFinite(a));b+=1)c=16*c+a;d+=String.fromCharCode(c)}else if('string'==typeof j[g])d+=j[g];else break}k('Bad string')},o=function(){for(;g&&' '>=g;)l()},p=function(){switch(g){case't':return l('t'),l('r'),l('u'),l('e'),!0;case'f':return l('f'),l('a'),l('l'),l('s'),l('e'),!1;case'n':return l('n'),l('u'),l('l'),l('l'),null;}k('Unexpected \''+g+'\'')},q=function(){var a=[];if('['===g){if(l('['),o(),']'===g)return l(']'),a;for(;g;){if(a.push(i()),o(),']'===g)return l(']'),a;l(','),o()}}k('Bad array')},r=function(){var a,b={};if('{'===g){if(l('{'),o(),'}'===g)return l('}'),b;for(;g;){if(a=n(),o(),l(':'),!0===e.strict&&Object.hasOwnProperty.call(b,a)&&k('Duplicate key "'+a+'"'),b[a]=i(),o(),'}'===g)return l('}'),b;l(','),o()}}k('Bad object')};i=function(){return o(),'{'===g?r():'['===g?q():'"'===g?n():'-'===g?m():'0'<=g&&'9'>=g?m():p()};var s,t,u,w,v=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,x=function(a,b,c){var e;if(s='',t='','number'==typeof c)for(e=0;e<c;e+=1)t+=' ';else'string'==typeof c&&(t=c);if(w=b,b&&'function'!=typeof b&&('object'!=typeof b||'number'!=typeof b.length))throw new Error('JSON.stringify');return d('',{"":a})},y=function(a,b){var c;return h=a+'',f=0,g=' ',c=i(),o(),g&&k('Syntax error'),'function'==typeof b?function a(c,d){var e,f=c[d];return f&&'object'==typeof f&&Object.keys(f).forEach(function(b){e=a(f,b),void 0===e?delete f[b]:f[b]=e}),b.call(c,d,f)}({"":c},''):c};return{parse:y,stringify:x}}}); |
{ | ||
"name": "parse-json-bignumber", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"dependencies": {}, | ||
@@ -8,9 +8,33 @@ "main": "dist/parse-json-bignumber.min.js", | ||
"build": "rm -rf ./dist && tsc -p ./ && babel ./dist/parse-json-bignumber.js -o ./dist/parse-json-bignumber.min.js", | ||
"prepare": "npm run build" | ||
"prepare": "npm run test && npm run build", | ||
"test": "node_modules/.bin/jest" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^23.3.1", | ||
"babel-cli": "^6.26.0", | ||
"babel-plugin-transform-es2015-modules-umd": "^6.24.1", | ||
"babel-preset-minify": "^0.3.0" | ||
"babel-preset-minify": "^0.3.0", | ||
"bignumber.js": "^7.2.1", | ||
"jest": "^23.5.0", | ||
"ts-jest": "^23.1.3", | ||
"typescript": "^3.0.1" | ||
}, | ||
"jest": { | ||
"collectCoverage": true, | ||
"coveragePathIgnorePatterns": [ | ||
"/node_modules/", | ||
"/test/" | ||
], | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js" | ||
], | ||
"transform": { | ||
"^.+\\.(ts|tsx)$": "ts-jest" | ||
}, | ||
"testMatch": [ | ||
"**/test/*.+(ts|tsx|js)" | ||
] | ||
} | ||
} |
@@ -266,41 +266,3 @@ const create = function (options?) { | ||
function checkIsBigNumber(some) { | ||
const methods = [ | ||
"absoluteValue", "abs", | ||
"comparedTo", | ||
"decimalPlaces", "dp", | ||
"dividedBy", "div", | ||
"dividedToIntegerBy", "idiv", | ||
"exponentiatedBy", "pow", | ||
"integerValue", | ||
"isEqualTo", "eq", | ||
"isFinite", | ||
"isGreaterThan", "gt", | ||
"isGreaterThanOrEqualTogte", | ||
"isInteger", | ||
"isLessThan", "lt", | ||
"isLessThanOrEqualTo", "lte", | ||
"isNaN", | ||
"isNegative", | ||
"isPositive", | ||
"isZero", | ||
"minus", | ||
"modulo", "mod", | ||
"multipliedBy", "times", | ||
"negated", | ||
"plus", | ||
"precision", "sd", | ||
"shiftedBy", | ||
"squareRoot", "sqrt", | ||
"toExponential", | ||
"toFixed", | ||
"toFormat", | ||
"toFraction", | ||
"toJSON", | ||
"toNumber", | ||
"toPrecision", | ||
"toString", | ||
"valueOf" | ||
]; | ||
return some && typeof some === 'object' && methods.every(m => m in some); | ||
return some && (options.BigNumber ? some instanceof options.BigNumber || options.BigNumber.isBigNumber(some) : false); | ||
} | ||
@@ -307,0 +269,0 @@ |
@@ -9,2 +9,5 @@ { | ||
}, | ||
"files": [ | ||
"src/parse-json-bignumber.ts" | ||
], | ||
"exclude": [ | ||
@@ -11,0 +14,0 @@ "node_modules" |
198504
20
1523
8