Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tomlify-j0.4

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tomlify-j0.4 - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

5

CHANGELOG.md

@@ -0,1 +1,6 @@

### v2.1.1
* New API `tomlify.toToml()`.
* Check for circular data structure in `tomlify.toValue()`.
### v2.0.0

@@ -2,0 +7,0 @@

20

dist/tomlify.min.js

@@ -1,12 +0,12 @@

(function(){function u(a,c,b){return p(a)?C(a,c,b):D(a,c,b)}function C(a,c,b){if(null==a)throw Error("Undefined or null cannot be stringified.");if(H(a))throw Error("Converting circular structure to TOML.");c="function"===typeof c?c:null;b=E(b);var d=[];x({path:[],table:{"":a},c:!1,b:!1,replace:c,level:0,a:b,f:d},"",a,function(a,b,c){if(p(c))""!==b&&(0<d.length&&d.push(""),b=a.b?"[["+y(a.path,!0)+"]]":"["+y(a.path,!0)+"]",d.push(r(b,a.level,a.a)));else if(t(c))if(k(b))v(c)||(b=B(a,b,c),k(b)&&d.push(r(b,
a.level,a.a)));else return!0;else return k(b)&&(b=B(a,b,c),k(b)&&d.push(r(b,a.level,a.a))),!0});return d.join("\n")}function E(a){return k(a)?a:"number"===typeof a&&0<=a&&isFinite(a)&&Math.floor(a)===a?F(" ",a):""}function r(a,c,b){c=F(b,c);return a.replace(/^(?!$)/mg,c)}function F(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 x(a,c,b,d){if(a.replace&&0===a.path.length){var f=z(a,c,b);k(f)&&a.f.push(f);if(!1!==f)return}if(!d(a,c,b)){var g=
(function(){function u(a,c,b){return p(a)?C(a,c,b):D(a,c,b)}function C(a,c,b){E(a);c="function"===typeof c?c:null;b=F(b);var d=[];x({path:[],table:{"":a},c:!1,b:!1,replace:c,level:0,a:b,f:d},"",a,function(a,b,c){if(p(c))""!==b&&(0<d.length&&d.push(""),b=a.b?"[["+y(a.path,!0)+"]]":"["+y(a.path,!0)+"]",d.push(r(b,a.level,a.a)));else if(t(c))if(k(b))v(c)||(b=B(a,b,c),k(b)&&d.push(r(b,a.level,a.a)));else return!0;else return k(b)&&(b=B(a,b,c),k(b)&&d.push(r(b,a.level,a.a))),!0});return d.join("\n")}function E(a){if(null==
a)throw Error("Undefined or null cannot be stringified.");if(I(a))throw Error("Converting circular structure to TOML.");}function F(a){return k(a)?a:"number"===typeof a&&0<=a&&isFinite(a)&&Math.floor(a)===a?G(" ",a):""}function r(a,c,b){c=G(b,c);return a.replace(/^(?!$)/mg,c)}function G(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 x(a,c,b,d){if(a.replace&&0===a.path.length){var f=z(a,c,b);k(f)&&a.f.push(f);if(!1!==f)return}if(!d(a,c,b)){var g=
a.table;a.table=b;if(t(b)){c=a.b;a.b=v(b);for(var e=0,n=b.length;e<n;e++)a.path.push(e),x(a,e,b[e],d),a.path.pop();a.b=c}else if(p(b)){c=a.b;a.b=!1;var l=[],m=[],h;for(h in b)Object.prototype.hasOwnProperty.call(b,h)&&(f=b[h],e=0<a.path.length&&(t(f)?v(f):p(f)),t(f)&&v(f)?m.push(h,f,e):p(f)?l.push(h,f,e):(a.path.push(h),x(a,h,f,d),a.path.pop()));if(a.replace){e=0;for(n=l.length;e<n;e+=3)a.path.push(l[e]),f=z(a,l[e],l[e+1]),!1!==f&&(k(f)&&a.f.push(r(f,a.level,a.a)),l[e+1]=null),a.path.pop();e=0;for(n=
m.length;e<n;e+=3){a.path.push(m[e]);f=z(a,m[e],m[e+1]);if(!1!==f)k(f)&&a.f.push(r(f,a.level,a.a)),m[e+1]=null;else for(b=0,h=m[e+1].length;b<h;b++)if(a.path.push(b),f=z(a,b,m[e+1][b]),a.path.pop(),!1!==f)if(null==f)m[e+1][b]=null;else{f=B(a,m[e],m[e+1]);k(f)&&a.f.push(r(f,a.level,a.a));m[e+1]=null;break}a.path.pop()}}h=l.concat(m);e=0;for(n=h.length;e<n;e+=3)null!=h[e+1]&&(a.path.push(h[e]),h[e+2]&&a.level++,x(a,h[e],h[e+1],d),h[e+2]&&a.level--,a.path.pop());a.b=c}a.table=g}}function z(a,c,b){if(a.replace){b=
a.replace.call({path:a.path.slice(0),table:a.table},c,b);if(k(b))return w(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 B(a,c,b){var d=w(c);if(!d)throw Error(l(a.path,"Key cannot be an empty string."));a=A(a,c,b);return k(a)?d+" = "+a:null}function w(a){return a?/^[a-zA-Z0-9\-_]+$/.test(a)?a:G(a):!1}function D(a,c,b){if(null==a)throw Error("Undefined or null cannot be stringified.");return A({path:[],
table:{"":a},b:!1,replace:"function"===typeof c?c:null,level:0,a:E(b)},"",a)}function A(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 G(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:a:{if(!(2>b.length)){var d=g(b[0]);c=1;for(var f=b.length;c<f;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."));d=a.table;a.table=b;c=[];f=a.c;v(b)&&(a.c=!0);for(var q=0,e=b.length;q<e;q++){a.path.push(q);var n=A(a,q,b[q]);k(n)&&c.push(n);a.path.pop()}a.c=f;a.table=d;return!a.c&&0<c.length&&a.a?"[\n"+r(c.join(",\n"),
1,a.a)+"\n]":"["+c.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;f=a.c;a.c=!0;q=[];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);e=A(a,d,b[d]);k(e)&&q.push(w(d)+" = "+e);a.path.pop()}a.c=f;a.table=c;a="{"+q.join(", ")+"}"}return a}}function G(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 H(a){function c(a,d){if(!t(a)&&!p(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(p(a[c]))return!0;return!1}function p(a){return null!==a&&"object"===typeof a&&!(t(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(y(a)||"<root>")+": "+c}function y(a,c){if(0===a.length)return"";for(var b="",d=0,f=a.length;d<f;d++)if(k(a[d])&&a[d])b+=(b?".":"")+w(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 t=Array.isArray||function(a){return g(a)===g.Array};u.toToml=function(a,c,b){if(!p(a))throw Error("An object other than Array or Date is expected.");return C(a,c,b)};u.toKey=function(a,c){if(k(a)){var b=w(a);if(!b)throw Error("Key cannot be an empty string.");return b}if(t(a)){b=y(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=D;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);
a.replace.call({path:a.path.slice(0),table:a.table},c,b);if(k(b))return w(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 B(a,c,b){var d=w(c);if(!d)throw Error(l(a.path,"Key cannot be an empty string."));a=A(a,c,b);return k(a)?d+" = "+a:null}function w(a){return a?/^[a-zA-Z0-9\-_]+$/.test(a)?a:H(a):!1}function D(a,c,b){E(a);return A({path:[],table:{"":a},b:!1,replace:"function"===typeof c?c:null,level:0,
a:F(b)},"",a)}function A(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 H(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:a:{if(!(2>b.length)){var d=g(b[0]);c=1;for(var f=b.length;c<f;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."));d=a.table;a.table=b;c=[];f=a.c;v(b)&&(a.c=!0);for(var q=0,e=b.length;q<e;q++){a.path.push(q);var n=A(a,q,b[q]);k(n)&&c.push(n);a.path.pop()}a.c=f;a.table=d;return!a.c&&0<c.length&&a.a?"[\n"+r(c.join(",\n"),1,a.a)+"\n]":"["+c.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;f=a.c;a.c=!0;q=[];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);e=A(a,d,b[d]);k(e)&&q.push(w(d)+" = "+e);a.path.pop()}a.c=f;a.table=c;a="{"+q.join(", ")+"}"}return a}}function H(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 I(a){function c(a,d){if(!t(a)&&!p(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(p(a[c]))return!0;
return!1}function p(a){return null!==a&&"object"===typeof a&&!(t(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(y(a)||"<root>")+": "+c}function y(a,c){if(0===a.length)return"";for(var b="",d=0,f=a.length;d<f;d++)if(k(a[d])&&a[d])b+=(b?".":"")+w(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 t=Array.isArray||function(a){return g(a)===g.Array};u.toToml=function(a,c,b){if(!p(a))throw Error("An object other than Array or Date is expected.");return C(a,c,b)};u.toKey=function(a,c){if(k(a)){var b=w(a);if(!b)throw Error("Key cannot be an empty string.");return b}if(t(a)){b=y(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=D;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);
{
"name": "tomlify-j0.4",
"version": "2.1.0",
"version": "2.1.1",
"description": "A Object->TOML encoder/converter only for TOML v0.4.0",

@@ -5,0 +5,0 @@ "main": "tomlify.js",

@@ -247,5 +247,3 @@ (function () {

var escapeValue = function (obj, replace, space) {
if (obj == null) {
throw new Error('Undefined or null cannot be stringified.');
}
check(obj);
return escapeValue_({

@@ -451,9 +449,13 @@ path: [],

var escapeTable = function (table, replace, space) {
if (table == null) {
var check = function (obj) {
if (obj == null) {
throw new Error('Undefined or null cannot be stringified.');
}
if (isCircular(table)) {
if (isCircular(obj)) {
throw new Error('Converting circular structure to TOML.');
}
};
var escapeTable = function (table, replace, space) {
check(table);
replace = toReplacer(replace);

@@ -460,0 +462,0 @@ space = toSpace(space);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc