instance-stringer
Version:
Convert content of a class instance to a string.
2 lines • 3.75 kB
JavaScript
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).instanceStringer=t()}}(function(){return function(){return function t(e,n,r){function o(c,u){if(!n[c]){if(!e[c]){var a="function"==typeof require&&require;if(!u&&a)return a(c,!0);if(i)return i(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var s=n[c]={exports:{}};e[c][0].call(s.exports,function(t){return o(e[c][1][t]||t)},s,s.exports,t,e,n,r)}return n[c].exports}for(var i="function"==typeof require&&require,c=0;c<r.length;c++)o(r[c]);return o}}()({1:[function(t,e,n){"use strict";const r=t("each-props"),o=t("is-plain-object");function i(t){const e=u(t);return o(t)?e:`${t.constructor.name} ${e}`}function c(t){return`[${t.map(t=>Array.isArray(t)?c(t):t instanceof Object?i(t):"string"==typeof t?`'${t}'`:t).join(", ")}]`}function u(t){let e="",n=0;return r(t,(t,r,u)=>{if(0===u.index?(e+="{ ",n=u.depth):(n>u.depth&&(e+=" }".repeat(n-u.depth),n=u.depth),e+=", "),Array.isArray(t))e+=`${u.name}: ${c(t)}`;else if(o(t))e+=`${u.name}: `,Object.keys(t).length||(e+="{}");else if(t instanceof Object)e+=`${u.name}: ${i(t)}`;else if("string"==typeof t)e+=`${u.name}: '${t}'`;else try{e+=`${u.name}: ${t}`}catch(t){e+=`${u.name}: {}`}}),(e+=" }".repeat(n)).length||(e="{}"),e}i.propsStringer=u,i.arrayStringer=c,e.exports=i},{"each-props":4,"is-plain-object":7}],2:[function(t,e,n){"use strict";e.exports=function(t,e,n){if(null!=t)for(var r=t.length,o=-1;++o<r;){var i=t[o];if(!1===e.call(n,i,o,t))break}}},{}],3:[function(t,e,n){"use strict";function r(t,e,n){return e=null==e?n||0:e<0?Math.max(t+e,0):Math.min(e,t)}e.exports=function(t,e,n){var o=t.length,i=[];for(e=r(o,e),n=r(o,n,o);e<n;)i.push(t[e++]);return i}},{}],4:[function(t,e,n){"use strict";var r=t("is-plain-object"),o=t("object.defaults/immutable");e.exports=function(t,e,n){var i;(i=t,"[object Object]"===Object.prototype.toString.call(i))&&("function"==typeof e&&(r(n)||(n={}),function t(e,n,i,c,u){var a=Object.keys(e);if("function"==typeof u.sort){var f=u.sort(a);Array.isArray(f)&&(a=f)}c+=1;for(var s=0,l=a.length;s<l;s++){var p=a[s],y=n+"."+p,b=e[p],d=o(u);d.name=p,d.index=s,d.count=l,d.depth=c,d.parent=e;var j=i(b,y.slice(1),d);!j&&r(b)&&t(b,y,i,c,u)}}(t,"",e,0,n)))}},{"is-plain-object":7,"object.defaults/immutable":9}],5:[function(t,e,n){"use strict";e.exports=function(t,e,n){for(var r in t)if(!1===e.call(n,t[r],r,t))break}},{}],6:[function(t,e,n){"use strict";var r=t("for-in"),o=Object.prototype.hasOwnProperty;e.exports=function(t,e,n){r(t,function(r,i){if(o.call(t,i))return e.call(n,t[i],i,t)})}},{"for-in":5}],7:[function(t,e,n){"use strict";var r=t("isobject");function o(t){return!0===r(t)&&"[object Object]"===Object.prototype.toString.call(t)}e.exports=function(t){var e,n;return!1!==o(t)&&("function"==typeof(e=t.constructor)&&(!1!==o(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")))}},{isobject:8}],8:[function(t,e,n){"use strict";e.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},{}],9:[function(t,e,n){"use strict";var r=t("array-slice"),o=t("./mutable");e.exports=function(){var t=r(arguments);return o.apply(null,[{}].concat(t))}},{"./mutable":10,"array-slice":3}],10:[function(t,e,n){"use strict";var r=t("array-each"),o=t("array-slice"),i=t("for-own"),c=t("isobject");e.exports=function(t,e){return null==t?{}:(r(o(arguments,1),function(e){c(e)&&i(e,function(e,n){null==t[n]&&(t[n]=e)})}),t)}},{"array-each":2,"array-slice":3,"for-own":6,isobject:8}]},{},[1])(1)});
//# sourceMappingURL=instance-stringer.min.js.map