-
Notifications
You must be signed in to change notification settings - Fork 0
/
hookney.min.js
2 lines (2 loc) · 2.46 KB
/
hookney.min.js
1
2
/*! hookney V1.2.0, Copyright (c) 2016-present, Belexos. MIT licensed. */
!function(e){const n="object"==typeof module&&module&&"object"==typeof module.exports,t=n?require("fs"):null,r=n?require("lodash"):e._,i="\\$\\{self\\:(.*?)\\}";function o(){"use strict";const e=arguments.length,o={};var s;for(s=0;s<e;s++)r.merge(o,arguments[s]);function l(e){var n,t,r,o;if(c(e))for(n in e)e.hasOwnProperty(n)&&(c(t=e[n])||f(t)?l(t):u(t)&&(e[n]=g(i,t)));else if(f(e))for(o=e.length,r=0;r<o;r++)c(t=e[r])||f(t)?l(t):u(t)&&(e[r]=g(i,t))}function g(e,n){const t=new RegExp(e,"gm").exec(n);var i;return t&&(i=r.get(o,t[1]),n=n===t[0]?i:n.replace(t[0],u(i)?i:JSON.stringify(i)),u(n)?n=g(e,n):"object"==typeof n&&l(n)),n}this.json=function(){return o},this.stringify=function(e,n){return JSON.stringify(o,e,n)},this.resolveReferences=function(){return l(o),this},n&&(this.writeFile=function(e,n,r){const i=this;r||(r=n,n={}),(n=n||{}).encoding||(n.encoding="utf8"),t.writeFile(e,this.stringify(n.replacer,n.space),n,(function(e){e?r(e,null):r(null,i)}))},this.writeFileSync=function(e,n){return(n=n||{}).encoding||(n.encoding="utf8"),t.writeFileSync(e,this.stringify(n.replacer,n.space),n),this})}function s(e){var n,t,r,i,o=/"|(\/\*)|(\*\/)|(\/\/)|\n|\r/g,s=!1,c=!1,f=!1,u=[],l=0,g=0;for(o.lastIndex=0;null!==(n=o.exec(e));)r=RegExp.leftContext,i=RegExp.rightContext,c||f||(t=r.substring(g),s||(t=t.replace(/(\n|\r|\s)*/g,"")),u[l++]=t),g=o.lastIndex,'"'!==n[0]||c||f?"/*"!==n[0]||s||c||f?"*/"!==n[0]||s||!c||f?"//"!==n[0]||s||c||f?"\n"!==n[0]&&"\r"!==n[0]||s||c||!f?c||f||/\n|\r|\s/.test(n[0])||(u[l++]=n[0]):f=!1:f=!0:c=!1:c=!0:(t=r.match(/(\\)*$/),s&&t&&t[0].length%2!=0||(s=!s),g--,i=e.substring(g));return u[l++]=i,u.join("")}function c(e){return"object"==typeof e&&!Array.isArray(e)}function f(e){return Array.isArray(e)}function u(e){return"string"==typeof e}n?module.exports=o:e.Hookney=o,o.from=function(){const e=arguments.length,n={};var t;for(t=0;t<e;t++)r.merge(n,arguments[t]);return new o(n)},o.fromString=function(e,n){var t={};return e&&u(e)&&e.length&&(e=s(e),t=JSON.parse(e,n)),new o(t)},n&&(o.fromFile=function(e,n,r){r||(r=n,n={}),(n=n||{}).encoding||(n.encoding="utf8"),t.readFile(e,n,(function(t,i){if(t)r(t,null);else{i=s(i);try{r(null,o.fromString(i,n.reviver))}catch(t){t.message=e+": "+t.message,r(t,null)}}}))},o.fromFileSync=function(e,n){var r;(n=n||{}).encoding||(n.encoding="utf8"),r=s(r=t.readFileSync(e,n));try{return o.fromString(r,n.reviver)}catch(n){throw n.message=e+": "+n.message,n}})}(this);