modl-converter
Advanced tools
Comparing version 0.0.16 to 0.0.17
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MODLConverter=t():e.MODLConverter=t()}(self,(function(){return(()=>{var e={43:function(e,t,n){var o,r;!function(u,i){"use strict";o=function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"];function r(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function u(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function i(o){return"debug"===o&&(o="log"),typeof console!==t&&("trace"===o&&n?u:void 0!==console[o]?r(console,o):void 0!==console.log?r(console,"log"):e)}function l(t,n){for(var r=0;r<o.length;r++){var u=o[r];this[u]=r<t?e:this.methodFactory(u,t,n)}this.log=this.debug}function c(e,n,o){return function(){typeof console!==t&&(l.call(this,n,o),this[e].apply(this,arguments))}}function s(e,t,n){return i(e)||c.apply(this,arguments)}function a(e,n,r){var u,i=this,c="loglevel";function a(){var e;if(typeof window!==t&&c){try{e=window.localStorage[c]}catch(e){}if(typeof e===t)try{var n=window.document.cookie,o=n.indexOf(encodeURIComponent(c)+"=");-1!==o&&(e=/^([^;]+)/.exec(n.slice(o))[1])}catch(e){}return void 0===i.levels[e]&&(e=void 0),e}}"string"==typeof e?c+=":"+e:"symbol"==typeof e&&(c=void 0),i.name=e,i.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},i.methodFactory=r||s,i.getLevel=function(){return u},i.setLevel=function(n,r){if("string"==typeof n&&void 0!==i.levels[n.toUpperCase()]&&(n=i.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=i.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(u=n,!1!==r&&function(e){var n=(o[e]||"silent").toUpperCase();if(typeof window!==t&&c){try{return void(window.localStorage[c]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+n+";"}catch(e){}}}(n),l.call(i,n,e),typeof console===t&&n<i.levels.SILENT)return"No console available for logging"},i.setDefaultLevel=function(e){a()||i.setLevel(e,!1)},i.enableAll=function(e){i.setLevel(i.levels.TRACE,e)},i.disableAll=function(e){i.setLevel(i.levels.SILENT,e)};var f=a();null==f&&(f=null==n?"WARN":n),i.setLevel(f,!1)}var f=new a,p={};f.getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=p[e];return t||(t=p[e]=new a(e,f.getLevel(),f.methodFactory)),t};var d=typeof window!==t?window.log:void 0;return f.noConflict=function(){return typeof window!==t&&window.log===f&&(window.log=d),f},f.getLoggers=function(){return p},f.default=f,f},void 0===(r=o.call(t,n,t,e))||(e.exports=r)}()},389:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createJsonToModl=void 0;var r=o(n(43)),u=n(494),i=n(902);t.createJsonToModl=function(){return new l};var l=function(){function e(){}return e.prototype.objectToModl=function(e){var t=Array.isArray(e)?s("",e):function(e){return null===e?"null":"object"!=typeof e||Array.isArray(e)?p(e):function(e){return"object"!=typeof e?v(e):Array.isArray(e)?a(e):Object.keys(e).map((function(t){return s(t,e[t])})).join(";")}(e)}(e);return r.default.debug("Result : ",t),t},e.prototype.stringToModl=function(e){r.default.debug("Converting: "+e);var t=JSON.parse(e);return this.objectToModl(t)},e}(),c=u.createUnicodeEscaper(),s=function(e,t){var n=c.escape(e);if(i.isNonStringPrimitive(n)&&(n='"'+n+'"'),null===t)return n+"=null";if(Array.isArray(t))return n+a(t);if("object"==typeof t)return""+n+f(t);var o=function(e,t){var n=v(t);return null!==n?e+"="+n:null}(n,t);return o||n+"="+p(t)};function a(e){return"["+e.map(d).join(";")+"]"}function f(e){return"object"!=typeof e?v(e):Array.isArray(e)?a(e):null===e?null:"("+Object.keys(e).map((function(t){return s(t,e[t])})).join(";")+")"}function p(e){return e&&Array.isArray(e)?a(e):e&&"object"==typeof e?f(e):v(e)}function d(e){return e&&Array.isArray(e)?a(e):e&&"object"==typeof e?function(e){if("object"!=typeof e)return v(e);if(Array.isArray(e))return a(e);if(null===e)return null;var t=Object.keys(e);return t.length>1?"("+t.map((function(t){return s(t,e[t])})).join(";")+")":0===t.length?"()":t.map((function(t){return s(t,e[t])})).join("")}(e):v(e)}var v=function(e){return null===e?"null":"string"==typeof e?"null"===e?"`null`":i.escapeAndQuote(e):"boolean"==typeof e?e?"true":"false":"number"==typeof e?Number.isInteger(e)?""+e:""+e.toExponential().replace("e+","E"):null}},494:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createUnicodeEscaper=void 0,t.createUnicodeEscaper=function(){return new n};var n=function(){function e(){}return e.prototype.escape=function(e){for(var t="",n=0;n<e.length;n++)t+=(o=e.charCodeAt(n))?o>=32&&o<=127?String.fromCodePoint(o):8===o?"\\b":12===o?"\\f":10===o?"\\n":13===o?"\\r":9===o?"\\t":o>=4096&&o<=65535?"~u"+o.toString(16):o>=256&&o<=4095?"~u0"+o.toString(16):o>=16&&o<=255?"~u00"+o.toString(16):"~u000"+o.toString(16):"";var o;return t},e}()},902:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNonStringPrimitive=t.escapeAndQuote=t.replaceNbspWithSp=t.doubleQuotesToGravesIfPossible=t.doubleQuoteIfNecessary=t.graveQuoteIfNecessary=t.escapeDoubleQuotes=t.isNumeric=t.shouldBeGraveQuoted=t.escapeGraves=void 0;var o=n(494);t.escapeGraves=function(e){return null!==e?e.replace(/`/g,"~`"):e},t.shouldBeGraveQuoted=new RegExp(".*[()\\[\\];{}=].*"),t.isNumeric=new RegExp("^[-]?[0-9]*\\.?[0-9]+(?:[Ee][+-]?[0-9]+)?$"),t.escapeDoubleQuotes=function(e){for(var t=e.indexOf('"',1),n=e;t>0&&t<e.length-1;)t=(n=n.substring(0,t)+"~u0022"+n.substring(t+1)).indexOf('"',1);return n},t.graveQuoteIfNecessary=function(e){return null!==e&&(t.shouldBeGraveQuoted.test(e)||""===e||t.isNumeric.test(e)&&"00"!==e&&"01"!==e&&"000"!==e||"true"===e||"false"===e||"null"===e||r(e))?"`"+e+"`":e};var r=function(e){return 0===e.trim().length};t.doubleQuoteIfNecessary=function(e){return null!==e&&e.includes("~`")?'"'+e+'"':e},t.doubleQuotesToGravesIfPossible=function(e){return null!==e&&!e.includes("~`")&&e.startsWith('"')&&e.endsWith('"')?"`"+e.substring(1,e.length-1)+"`":e},t.replaceNbspWithSp=function(e){return e.replace(/\u00a0/g," ")};var u=o.createUnicodeEscaper();t.escapeAndQuote=function(e){return null===e?e:t.doubleQuotesToGravesIfPossible(t.doubleQuoteIfNecessary(t.graveQuoteIfNecessary(t.escapeGraves(u.escape(t.replaceNbspWithSp(t.escapeDoubleQuotes(e)))))))},t.isNonStringPrimitive=function(e){return i.includes(e)||t.isNumeric.test(e)};var i=["true","false","null"]}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var u=t[o]={exports:{}};return e[o].call(u.exports,u,u.exports,n),u.exports}var o={};return(()=>{"use strict";var e=o;Object.defineProperty(e,"__esModule",{value:!0}),e.jsonToModl=void 0;var t=n(389);e.jsonToModl=t.createJsonToModl()})(),o})()})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MODLConverter=t():e.MODLConverter=t()}(self,(function(){return(()=>{var e={43:function(e,t,n){var o,r;!function(u,i){"use strict";o=function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"];function r(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function u(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function i(o){return"debug"===o&&(o="log"),typeof console!==t&&("trace"===o&&n?u:void 0!==console[o]?r(console,o):void 0!==console.log?r(console,"log"):e)}function l(t,n){for(var r=0;r<o.length;r++){var u=o[r];this[u]=r<t?e:this.methodFactory(u,t,n)}this.log=this.debug}function c(e,n,o){return function(){typeof console!==t&&(l.call(this,n,o),this[e].apply(this,arguments))}}function s(e,t,n){return i(e)||c.apply(this,arguments)}function a(e,n,r){var u,i=this,c="loglevel";function a(){var e;if(typeof window!==t&&c){try{e=window.localStorage[c]}catch(e){}if(typeof e===t)try{var n=window.document.cookie,o=n.indexOf(encodeURIComponent(c)+"=");-1!==o&&(e=/^([^;]+)/.exec(n.slice(o))[1])}catch(e){}return void 0===i.levels[e]&&(e=void 0),e}}"string"==typeof e?c+=":"+e:"symbol"==typeof e&&(c=void 0),i.name=e,i.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},i.methodFactory=r||s,i.getLevel=function(){return u},i.setLevel=function(n,r){if("string"==typeof n&&void 0!==i.levels[n.toUpperCase()]&&(n=i.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=i.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(u=n,!1!==r&&function(e){var n=(o[e]||"silent").toUpperCase();if(typeof window!==t&&c){try{return void(window.localStorage[c]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+n+";"}catch(e){}}}(n),l.call(i,n,e),typeof console===t&&n<i.levels.SILENT)return"No console available for logging"},i.setDefaultLevel=function(e){a()||i.setLevel(e,!1)},i.enableAll=function(e){i.setLevel(i.levels.TRACE,e)},i.disableAll=function(e){i.setLevel(i.levels.SILENT,e)};var f=a();null==f&&(f=null==n?"WARN":n),i.setLevel(f,!1)}var f=new a,p={};f.getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=p[e];return t||(t=p[e]=new a(e,f.getLevel(),f.methodFactory)),t};var d=typeof window!==t?window.log:void 0;return f.noConflict=function(){return typeof window!==t&&window.log===f&&(window.log=d),f},f.getLoggers=function(){return p},f.default=f,f},void 0===(r=o.call(t,n,t,e))||(e.exports=r)}()},389:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createJsonToModl=void 0;var r=o(n(43)),u=n(494),i=n(902);t.createJsonToModl=function(){return new l};var l=function(){function e(){}return e.prototype.objectToModl=function(e){var t=Array.isArray(e)?s("",e):function(e){return null===e?"null":"object"!=typeof e||Array.isArray(e)?p(e):function(e){return"object"!=typeof e?v(e):Array.isArray(e)?a(e):Object.keys(e).map((function(t){return s(t,e[t])})).join(";")}(e)}(e);return r.default.debug("Result : ",t),t},e.prototype.stringToModl=function(e){r.default.debug("Converting: "+e);var t=JSON.parse(e);return this.objectToModl(t)},e}(),c=u.createUnicodeEscaper(),s=function(e,t){var n=c.escape(e);if(i.isNonStringPrimitive(n)&&(n='"'+n+'"'),null===t)return n+"=null";if(Array.isArray(t))return n+a(t);if("object"==typeof t)return""+n+f(t);var o=function(e,t){var n=v(t);return null!==n?e+"="+n:null}(n,t);return o||n+"="+p(t)};function a(e){return"["+e.map(d).join(";")+"]"}function f(e){return"object"!=typeof e?v(e):Array.isArray(e)?a(e):null===e?null:"("+Object.keys(e).map((function(t){return s(t,e[t])})).join(";")+")"}function p(e){return e&&Array.isArray(e)?a(e):e&&"object"==typeof e?f(e):v(e)}function d(e){return e&&Array.isArray(e)?a(e):e&&"object"==typeof e?function(e){if("object"!=typeof e)return v(e);if(Array.isArray(e))return a(e);if(null===e)return null;var t=Object.keys(e);return t.length>1?"("+t.map((function(t){return s(t,e[t])})).join(";")+")":0===t.length?"()":t.map((function(t){return s(t,e[t])})).join("")}(e):v(e)}var v=function(e){return null===e?"null":"string"==typeof e?"null"===e?"`null`":i.escapeAndQuote(e):"boolean"==typeof e?e?"true":"false":"number"==typeof e?Number.isInteger(e)?""+e:""+e.toExponential().replace("e+","E"):null}},494:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createUnicodeEscaper=void 0,t.createUnicodeEscaper=function(){return new n};var n=function(){function e(){}return e.prototype.escape=function(e){for(var t="",n=e.replace(/~u/g,"~~u"),o=0;o<n.length;o++)t+=(r=n.charCodeAt(o))?r>=32&&r<=127?String.fromCodePoint(r):8===r?"\\b":12===r?"\\f":10===r?"\\n":13===r?"\\r":9===r?"\\t":r>=4096&&r<=65535?"~u"+r.toString(16):r>=256&&r<=4095?"~u0"+r.toString(16):r>=16&&r<=255?"~u00"+r.toString(16):"~u000"+r.toString(16):"";var r;return t},e}()},902:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNonStringPrimitive=t.escapeAndQuote=t.replaceNbspWithSp=t.doubleQuotesToGravesIfPossible=t.doubleQuoteIfNecessary=t.graveQuoteIfNecessary=t.escapeDoubleQuotes=t.isNumeric=t.shouldBeGraveQuoted=t.escapeGraves=void 0;var o=n(494);t.escapeGraves=function(e){return null!==e?e.replace(/`/g,"~`"):e},t.shouldBeGraveQuoted=new RegExp(".*[()\\[\\];{}=].*"),t.isNumeric=new RegExp("^[-]?[0-9]*\\.?[0-9]+(?:[Ee][+-]?[0-9]+)?$"),t.escapeDoubleQuotes=function(e){for(var t=e.indexOf('"',1),n=e;t>0&&t<e.length-1;)t=(n=n.substring(0,t)+"~u0022"+n.substring(t+1)).indexOf('"',1);return n},t.graveQuoteIfNecessary=function(e){return null!==e&&(t.shouldBeGraveQuoted.test(e)||""===e||t.isNumeric.test(e)&&"00"!==e&&"01"!==e&&"000"!==e||"true"===e||"false"===e||"null"===e||r(e))?"`"+e+"`":e};var r=function(e){return 0===e.trim().length};t.doubleQuoteIfNecessary=function(e){return null!==e&&e.includes("~`")?'"'+e+'"':e},t.doubleQuotesToGravesIfPossible=function(e){return null!==e&&!e.includes("~`")&&e.startsWith('"')&&e.endsWith('"')?"`"+e.substring(1,e.length-1)+"`":e},t.replaceNbspWithSp=function(e){return e.replace(/\u00a0/g," ")};var u=o.createUnicodeEscaper();t.escapeAndQuote=function(e){return null===e?e:t.doubleQuotesToGravesIfPossible(t.doubleQuoteIfNecessary(t.graveQuoteIfNecessary(t.escapeGraves(t.escapeDoubleQuotes(u.escape(t.replaceNbspWithSp(e)))))))},t.isNonStringPrimitive=function(e){return i.includes(e)||t.isNumeric.test(e)};var i=["true","false","null"]}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var u=t[o]={exports:{}};return e[o].call(u.exports,u,u.exports,n),u.exports}var o={};return(()=>{"use strict";var e=o;Object.defineProperty(e,"__esModule",{value:!0}),e.jsonToModl=void 0;var t=n(389);e.jsonToModl=t.createJsonToModl()})(),o})()})); |
@@ -13,4 +13,5 @@ "use strict"; | ||
var result = ''; | ||
for (var i = 0; i < s.length; i++) { | ||
var cp = s.charCodeAt(i); | ||
var str = s.replace(/~u/g, '~~u'); | ||
for (var i = 0; i < str.length; i++) { | ||
var cp = str.charCodeAt(i); | ||
result += escapeChar(cp); | ||
@@ -17,0 +18,0 @@ } |
@@ -51,3 +51,3 @@ "use strict"; | ||
} | ||
return exports.doubleQuotesToGravesIfPossible(exports.doubleQuoteIfNecessary(exports.graveQuoteIfNecessary(exports.escapeGraves(unicodeEscaper.escape(exports.replaceNbspWithSp(exports.escapeDoubleQuotes(s))))))); | ||
return exports.doubleQuotesToGravesIfPossible(exports.doubleQuoteIfNecessary(exports.graveQuoteIfNecessary(exports.escapeGraves(exports.escapeDoubleQuotes(unicodeEscaper.escape(exports.replaceNbspWithSp(s))))))); | ||
}; | ||
@@ -54,0 +54,0 @@ exports.escapeAndQuote = escapeAndQuote; |
{ | ||
"name": "modl-converter", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"description": "A JSON to MODL library in TypeScript", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -12,4 +12,5 @@ export interface UnicodeEscaper { | ||
let result = ''; | ||
for (let i = 0; i < s.length; i++) { | ||
const cp = s.charCodeAt(i); | ||
const str = s.replace(/~u/g, '~~u'); | ||
for (let i = 0; i < str.length; i++) { | ||
const cp = str.charCodeAt(i); | ||
result += escapeChar(cp); | ||
@@ -16,0 +17,0 @@ } |
@@ -74,3 +74,3 @@ import { createUnicodeEscaper } from './UnicodeEscaper'; | ||
return doubleQuotesToGravesIfPossible( | ||
doubleQuoteIfNecessary(graveQuoteIfNecessary(escapeGraves(unicodeEscaper.escape(replaceNbspWithSp(escapeDoubleQuotes(s)))))) | ||
doubleQuoteIfNecessary(graveQuoteIfNecessary(escapeGraves(escapeDoubleQuotes(unicodeEscaper.escape(replaceNbspWithSp(s)))))) | ||
); | ||
@@ -77,0 +77,0 @@ }; |
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
39325
617