forked from kolman/icepick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
icepick.dev.js
1 lines (1 loc) · 3.59 KB
/
icepick.dev.js
1
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).icepick=e()}}(function(){return function e(n,r,t){function o(i,u){if(!r[i]){if(!n[i]){var f="function"==typeof require&&require;if(!u&&f)return f(i,!0);if(c)return c(i,!0);var s=new Error("Cannot find module '"+i+"'");throw s.code="MODULE_NOT_FOUND",s}var a=r[i]={exports:{}};n[i][0].call(a.exports,function(e){var r=n[i][1][e];return o(r||e)},a,a.exports,e,n,r,t)}return r[i].exports}for(var c="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({1:[function(e,n,r){"use strict";function t(e,n){return(n||[]).reduce(function(e,n){if(e)return e[n]},e)}function o(e,n){return Object.keys(n).reduce(function(e,r){return u.assoc(e,r,n[r])},e)}function c(e,n,r){return null==e||null==n?e:Object.keys(n).reduce(function(e,t){var o=n[t],s=e[t],a=r?r(s,o,t):o;return f(o)&&f(s)?a===s&&Object.isFrozen(a)&&Object.isFrozen(s)?e:Array.isArray(o)?u.assoc(e,t,a):i(e,t,c(s,a,r)):i(e,t,a)},e)}function i(e,n,r){return e[n]===r?e:u.assoc(e,n,r)}var u=r,f=function(e){return null!==e&&(Array.isArray(e)||s(e))},s=function(e){return"object"==typeof e&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype},a=function(e,n){var r,t;if(Array.isArray(e))for(r=e.length;r--;)n(r);else for(r=(t=Object.keys(e)).length;r--;)n(t[r])},l=function(e){for(var n,r={},t=Object.keys(e),o=t.length;o--;)r[n=t[o]]=e[n];return r},p=function(e){return Array.isArray(e)?e.slice():l(e)},h=function(e){return f(e)&&!Object.isFrozen(e)?d(e):e},v=function(e){return"object"==typeof e?Object.freeze(e):e},y=[],d=function(e){if(y.some(function(n){return n===e}))throw new Error("object has a reference cycle");return y.push(e),a(e,function(n){var r=e[n];f(r)&&d(r)}),y.pop(),Object.freeze(e),e};r.freeze=d,r.thaw=function e(n){if(!f(n)||!Object.isFrozen(n))return n;var r=Array.isArray(n)?new Array(n.length):{};return a(n,function(t){r[t]=e(n[t])}),r},r.assoc=function(e,n,r){if(e[n]===r)return v(e);var t=p(e);return t[n]=h(r),v(t)},r.set=r.assoc,r.dissoc=function(e,n){var r=p(e);return delete r[n],v(r)},r.unset=r.dissoc,r.assocIn=function e(n,r,t){var o=r[0];return 1===r.length?u.assoc(n,o,t):u.assoc(n,o,e(n[o]||{},r.slice(1),t))},r.setIn=r.assocIn,r.dissocIn=function e(n,r){var t=r[0];return n.hasOwnProperty(t)?1===r.length?u.dissoc(n,t):u.assoc(n,t,e(n[t],r.slice(1))):n},r.unsetIn=r.dissocIn,r.getIn=t,r.updateIn=function(e,n,r){var o=t(e,n);return u.assocIn(e,n,r(o))},["push","unshift","pop","shift","reverse","sort"].forEach(function(e){r[e]=function(n,r){var t=[].concat(n);return t[e](h(r)),v(t)},r[e].displayName="icepick."+e}),r.splice=function(e){for(var n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];var t=[].concat(e),o=n.map(h);return t.splice.apply(t,o),v(t)},r.slice=function(e,n,r){var t=e.slice(n,r);return v(t)},["map","filter"].forEach(function(e){r[e]=function(n,r){var t=r[e](n);return v(t)},r[e].displayName="icepick."+e}),r.extend=r.assign=function(e){for(var n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];var t=n.reduce(o,e);return v(t)},r.merge=c;var b={value:function(){return this.val},thru:function(e){return this.val=h(e(this.val)),this}};Object.keys(r).forEach(function(e){e.match(/^(map|filter)$/)?b[e]=function(n){return this.val=r[e](n,this.val),this}:b[e]=function(){for(var n=[],t=arguments.length;t--;)n[t]=arguments[t];return this.val=r[e].apply(r,[this.val].concat(n)),this}}),r.chain=function(e){var n=Object.create(b);return n.val=e,n}},{}]},{},[1])(1)});