tomlify-j0.4
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -1,12 +0,12 @@ | ||
;(function(){'use strict';function u(a,c,b){if(null==a)throw Error("Undefined or null cannot be stringified.");if(F(a))throw Error("Converting circular structure to TOML.");c="function"===typeof c?c:null;b=B(b);if(!n(a))return C(a,c,b);var d=[];w({path:[],table:{"":a},b:!1,replace:c,level:0,a:b,c:d},"",a,function(a,b,c){if(n(c))""!==b&&(0<d.length&&d.push(""),b=a.b?"[["+x(a.path,!0)+"]]":"["+x(a.path,!0)+"]",d.push(r(b,a.level,a.a)));else if(p(c))if(k(b))v(c)||(b=A(a,b,c),k(b)&&d.push(r(b,a.level,a.a)));else return!0; | ||
else return k(b)&&(b=A(a,b,c),k(b)&&d.push(r(b,a.level,a.a))),!0});return d.join("\n")}function B(a){return k(a)?a:"number"===typeof a&&0<=a&&isFinite(a)&&Math.floor(a)===a?D(" ",a):""}function r(a,c,b){c=D(b,c);return a.replace(/^(?!$)/mg,c)}function D(a,c){if(a.repeat)return a.repeat(c);for(var b="",d="";0<c;)d+=d||a,c&1&&(b+=d),c>>>=1;return b}function w(a,c,b,d){var e;if(a.replace&&0===a.path.length&&(e=y(a,c,b),k(e)&&a.c.push(e),!1!==e))return;if(!d(a,c,b)){c=a.table;a.table=b;if(p(b)){var g= | ||
a.b;a.b=v(b);for(var f=0,l=b.length;f<l;f++)a.path.push(f),w(a,f,b[f],d),a.path.pop();a.b=g}else if(n(b)){g=a.b;a.b=!1;var q=[],m=[],h;for(h in b)Object.prototype.hasOwnProperty.call(b,h)&&(e=b[h],f=0<a.path.length&&(p(e)?v(e):n(e)),p(e)&&v(e)?m.push(h,e,f):n(e)?q.push(h,e,f):(a.path.push(h),w(a,h,e,d),a.path.pop()));if(a.replace){f=0;for(l=q.length;f<l;f+=3)a.path.push(q[f]),e=y(a,q[f],q[f+1]),k(e)?(a.c.push(r(e,a.level,a.a)),q[f+1]=null):null==e&&(q[f+1]=null),a.path.pop();f=0;for(l=m.length;f< | ||
l;f+=3){a.path.push(m[f]);e=y(a,m[f],m[f+1]);if(k(e))e=t(m[f])+" = "+e,a.c.push(r(e,a.level,a.a));else if(null==e){m[f+1]=null;a.path.pop();continue}b=0;for(h=m[f+1].length;b<h;b++)if(a.path.push(b),e=y(a,b,m[f+1][b]),a.path.pop(),null==e)m[f+1][b]=null;else if(!1!==e){e=A(a,m[f],m[f+1]);k(e)&&a.c.push(r(e,a.level,a.a));m[f+1]=null;break}a.path.pop()}}h=q.concat(m);f=0;for(l=h.length;f<l;f+=3)null!=h[f+1]&&(a.path.push(h[f]),h[f+2]&&a.level++,w(a,h[f],h[f+1],d),h[f+2]&&a.level--,a.path.pop());a.b= | ||
g}a.table=c}}function y(a,c,b){if(a.replace){b=a.replace.call({path:a.path.slice(0),table:a.table},c,b);if(k(b))return t(c)+" = "+b;if(null==b)return null;if(!1!==b)throw Error(l(a.path,"Replacer must return a string, false, null or undefined."));}return!1}function A(a,c,b){var d=t(c);if(!d)throw Error(l(a.path,"Key cannot be an empty string."));a=z(a,c,b);return k(a)?d+" = "+a:null}function t(a){return a?/^[a-zA-Z0-9\-_]+$/.test(a)?a:E(a):!1}function C(a,c,b){if(null==a)throw Error("Undefined or null cannot be stringified."); | ||
return z({path:[],table:{"":a},b:!1,replace:"function"===typeof c?c:null,level:0,a:B(b)},"",a)}function z(a,c,b){if(a.replace){c=a.replace.call({path:a.path.slice(0),table:a.table},c,b);if(k(c))return c;if(null==c)return null;if(!1!==c)throw Error(l(a.path,"Replacer must return a string, false, null or undefined."));}switch(g(b)){case g.Boolean:return b?"true":"false";case g.String:return E(b);case g.Number:if(!isFinite(b))throw Error(l(a.path,"Number must be finite."));a=(Number.isInteger?Number.isInteger(b): | ||
Math.floor(b)===b)?b.toFixed(1):String(b);a=a.replace(/([eE])(\d)/,"$1+$2");return/[.eE]/.test(a)?a:a+".0";case g.Array:var d;a:{if(!(2>b.length)){d=g(b[0]);c=1;for(var e=b.length;c<e;c++)if(null!=b[c]&&g(b[c])!==d){d=!0;break a}}d=!1}if(d)throw Error(l(a.path,"Array cannot contain values of different types."));c=a.table;a.table=b;d=[];for(var e=0,n=b.length;e<n;e++){a.path.push(e);var f=z(a,e,b[e]);k(f)&&d.push(f);a.path.pop()}a.table=c;if(c=0<d.length&&a.a){a:{if(!(1>b.length))for(c=0,e=b.length;c< | ||
e;c++)if(p(b[c])){c=!0;break a}c=!1}c=c||v(b)}return c?"[\n"+r(d.join(",\n"),1,a.a)+"\n]":"["+d.join(", ")+"]";case g.Date:if(!isFinite(b.getTime()))throw Error(l(a.path,"Invalid Date"));return b.toISOString();default:if(null==b)a=null;else{c=a.table;a.table=b;e=[];for(d in b)if(Object.prototype.hasOwnProperty.call(b,d)&&null!=b[d]){if(!d)throw Error(l(a.path,"Key cannot be an empty string."));a.path.push(d);n=z(a,d,b[d]);k(n)&&e.push(t(d)+" = "+n);a.path.pop()}a.table=c;a="{"+e.join(", ")+"}"}return a}} | ||
function E(a){return"object"===typeof JSON&&JSON?JSON.stringify(a):'"'+String(a).replace(/[\x00-\x1F"\\]/g,function(a){switch(a){case '"':case "\\":return"\\"+a;case "\t":return"\\t";case "\n":return"\\n";case "\r":return"\\r";case "\b":return"\\b";case "\f":return"\\f";default:return a=a.charCodeAt(0).toString(16),"\\u"+"0000".substr(a.length)+a}})+'"'}function F(a){function c(a,d){if(!p(a)&&!n(a))return!1;if(-1!==d.indexOf(a))return!0;d.push(a);for(var b in a)if(Object.prototype.hasOwnProperty.call(a, | ||
b)){var g=d.length;if(c(a[b],d))return!0;d.splice(g)}return!1}return c(a,[])}function v(a){if(1>a.length)return!1;for(var c=0,b=a.length;c<b;c++)if(n(a[c]))return!0;return!1}function n(a){return null!==a&&"object"===typeof a&&!(p(a)||g(a)===g.Date)}function k(a){return"string"===typeof a}function g(a){return Object.prototype.toString.call(a)}function l(a,c){return(x(a)||"<root>")+": "+c}function x(a,c){if(0===a.length)return"";for(var b="",d=0,e=a.length;d<e;d++)if(k(a[d])&&a[d])b+=(b?".":"")+t(a[d]); | ||
else if("number"===typeof a[d])c||(b+=(b?".":"")+"["+a[d]+"]");else return!1;return b?b:!1}g.Boolean=g(!1);g.String=g("");g.Number=g(0);g.Array=g([]);g.Date=g(new Date(0));var p=Array.isArray||function(a){return g(a)===g.Array};u.toKey=function(a,c){if(k(a)){var b=t(a);if(!b)throw Error("Key cannot be an empty string.");return b}if(p(a)){b=x(a,c);if(!1===b)throw Error("Key path must consist of non-empty string(s).");return b}throw Error("Invalid Arguments for tomlify.toKey({String | Array})");};u.toValue= | ||
C;null!=("undefined"!==typeof module&&null!==module?module.exports:void 0)?module.exports=u:"function"===typeof define&&define.amd?define([],function(){return u}):this.tomlify=u}).call(this); | ||
;(function(){'use strict';function t(a,c,b){if(null==a)throw Error("Undefined or null cannot be stringified.");if(F(a))throw Error("Converting circular structure to TOML.");c="function"===typeof c?c:null;b=B(b);if(!n(a))return C(a,c,b);var d=[];w({path:[],table:{"":a},b:!1,replace:c,level:0,a:b,c:d},"",a,function(a,b,c){if(n(c))""!==b&&(0<d.length&&d.push(""),b=a.b?"[["+x(a.path,!0)+"]]":"["+x(a.path,!0)+"]",d.push(q(b,a.level,a.a)));else if(p(c))if(k(b))u(c)||(b=A(a,b,c),k(b)&&d.push(q(b,a.level,a.a)));else return!0; | ||
else return k(b)&&(b=A(a,b,c),k(b)&&d.push(q(b,a.level,a.a))),!0});return d.join("\n")}function B(a){return k(a)?a:"number"===typeof a&&0<=a&&isFinite(a)&&Math.floor(a)===a?D(" ",a):""}function q(a,c,b){c=D(b,c);return a.replace(/^(?!$)/mg,c)}function D(a,c){if(a.repeat)return a.repeat(c);for(var b="",d="";0<c;)d+=d||a,c&1&&(b+=d),c>>>=1;return b}function w(a,c,b,d){var e;if(a.replace&&0===a.path.length&&(e=y(a,c,b),k(e)&&a.c.push(e),!1!==e))return;if(!d(a,c,b)){c=a.table;a.table=b;if(p(b)){var g= | ||
a.b;a.b=u(b);for(var f=0,l=b.length;f<l;f++)a.path.push(f),w(a,f,b[f],d),a.path.pop();a.b=g}else if(n(b)){g=a.b;a.b=!1;var r=[],m=[],h;for(h in b)Object.prototype.hasOwnProperty.call(b,h)&&(e=b[h],f=0<a.path.length&&(p(e)?u(e):n(e)),p(e)&&u(e)?m.push(h,e,f):n(e)?r.push(h,e,f):(a.path.push(h),w(a,h,e,d),a.path.pop()));if(a.replace){f=0;for(l=r.length;f<l;f+=3)a.path.push(r[f]),e=y(a,r[f],r[f+1]),!1!==e&&(k(e)&&a.c.push(q(e,a.level,a.a)),r[f+1]=null),a.path.pop();f=0;for(l=m.length;f<l;f+=3){a.path.push(m[f]); | ||
e=y(a,m[f],m[f+1]);if(!1!==e)k(e)&&a.c.push(q(e,a.level,a.a)),m[f+1]=null;else for(b=0,h=m[f+1].length;b<h;b++)if(a.path.push(b),e=y(a,b,m[f+1][b]),a.path.pop(),!1!==e)if(null==e)m[f+1][b]=null;else{e=A(a,m[f],m[f+1]);k(e)&&a.c.push(q(e,a.level,a.a));m[f+1]=null;break}a.path.pop()}}h=r.concat(m);f=0;for(l=h.length;f<l;f+=3)null!=h[f+1]&&(a.path.push(h[f]),h[f+2]&&a.level++,w(a,h[f],h[f+1],d),h[f+2]&&a.level--,a.path.pop());a.b=g}a.table=c}}function y(a,c,b){if(a.replace){b=a.replace.call({path:a.path.slice(0), | ||
table:a.table},c,b);if(k(b))return v(c)+" = "+b;if(null==b)return null;if(!1!==b)throw Error(l(a.path,"Replacer must return a string, false, null or undefined."));}return!1}function A(a,c,b){var d=v(c);if(!d)throw Error(l(a.path,"Key cannot be an empty string."));a=z(a,c,b);return k(a)?d+" = "+a:null}function v(a){return a?/^[a-zA-Z0-9\-_]+$/.test(a)?a:E(a):!1}function C(a,c,b){if(null==a)throw Error("Undefined or null cannot be stringified.");return z({path:[],table:{"":a},b:!1,replace:"function"=== | ||
typeof c?c:null,level:0,a:B(b)},"",a)}function z(a,c,b){if(a.replace){c=a.replace.call({path:a.path.slice(0),table:a.table},c,b);if(k(c))return c;if(null==c)return null;if(!1!==c)throw Error(l(a.path,"Replacer must return a string, false, null or undefined."));}switch(g(b)){case g.Boolean:return b?"true":"false";case g.String:return E(b);case g.Number:if(!isFinite(b))throw Error(l(a.path,"Number must be finite."));a=(Number.isInteger?Number.isInteger(b):Math.floor(b)===b)?b.toFixed(1):String(b);a= | ||
a.replace(/([eE])(\d)/,"$1+$2");return/[.eE]/.test(a)?a:a+".0";case g.Array:var d;a:{if(!(2>b.length)){d=g(b[0]);c=1;for(var e=b.length;c<e;c++)if(null!=b[c]&&g(b[c])!==d){d=!0;break a}}d=!1}if(d)throw Error(l(a.path,"Array cannot contain values of different types."));c=a.table;a.table=b;d=[];for(var e=0,n=b.length;e<n;e++){a.path.push(e);var f=z(a,e,b[e]);k(f)&&d.push(f);a.path.pop()}a.table=c;if(c=0<d.length&&a.a){a:{if(!(1>b.length))for(c=0,e=b.length;c<e;c++)if(p(b[c])){c=!0;break a}c=!1}c=c|| | ||
u(b)}return c?"[\n"+q(d.join(",\n"),1,a.a)+"\n]":"["+d.join(", ")+"]";case g.Date:if(!isFinite(b.getTime()))throw Error(l(a.path,"Invalid Date"));return b.toISOString();default:if(null==b)a=null;else{c=a.table;a.table=b;e=[];for(d in b)if(Object.prototype.hasOwnProperty.call(b,d)&&null!=b[d]){if(!d)throw Error(l(a.path,"Key cannot be an empty string."));a.path.push(d);n=z(a,d,b[d]);k(n)&&e.push(v(d)+" = "+n);a.path.pop()}a.table=c;a="{"+e.join(", ")+"}"}return a}}function E(a){return"object"===typeof JSON&& | ||
JSON?JSON.stringify(a):'"'+String(a).replace(/[\x00-\x1F"\\]/g,function(a){switch(a){case '"':case "\\":return"\\"+a;case "\t":return"\\t";case "\n":return"\\n";case "\r":return"\\r";case "\b":return"\\b";case "\f":return"\\f";default:return a=a.charCodeAt(0).toString(16),"\\u"+"0000".substr(a.length)+a}})+'"'}function F(a){function c(a,d){if(!p(a)&&!n(a))return!1;if(-1!==d.indexOf(a))return!0;d.push(a);for(var b in a)if(Object.prototype.hasOwnProperty.call(a,b)){var g=d.length;if(c(a[b],d))return!0; | ||
d.splice(g)}return!1}return c(a,[])}function u(a){if(1>a.length)return!1;for(var c=0,b=a.length;c<b;c++)if(n(a[c]))return!0;return!1}function n(a){return null!==a&&"object"===typeof a&&!(p(a)||g(a)===g.Date)}function k(a){return"string"===typeof a}function g(a){return Object.prototype.toString.call(a)}function l(a,c){return(x(a)||"<root>")+": "+c}function x(a,c){if(0===a.length)return"";for(var b="",d=0,e=a.length;d<e;d++)if(k(a[d])&&a[d])b+=(b?".":"")+v(a[d]);else if("number"===typeof a[d])c||(b+= | ||
(b?".":"")+"["+a[d]+"]");else return!1;return b?b:!1}g.Boolean=g(!1);g.String=g("");g.Number=g(0);g.Array=g([]);g.Date=g(new Date(0));var p=Array.isArray||function(a){return g(a)===g.Array};t.toKey=function(a,c){if(k(a)){var b=v(a);if(!b)throw Error("Key cannot be an empty string.");return b}if(p(a)){b=x(a,c);if(!1===b)throw Error("Key path must consist of non-empty string(s).");return b}throw Error("Invalid Arguments for tomlify.toKey({String | Array})");};t.toValue=C;null!=("undefined"!==typeof module&& | ||
null!==module?module.exports:void 0)?module.exports=t:"function"===typeof define&&define.amd?define([],function(){return t}):this.tomlify=t}).call(this); |
{ | ||
"name": "tomlify-j0.4", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A Object->TOML encoder/converter only for TOML v0.4.0", | ||
@@ -5,0 +5,0 @@ "main": "tomlify.js", |
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
532
28775