UNPKG

@dillonkearns/elm-graphql

Version:

<img src="https://cdn.jsdelivr.net/gh/martimatix/logo-graphqelm/logo.svg" alt="dillonearns/elm-graphql logo" width="40%" align="right">

3 lines (2 loc) 2.88 kB
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var _Symbol=_interopDefault(require("babel-runtime/core-js/symbol")),_extends=_interopDefault(require("babel-runtime/helpers/extends")),_newArrowCheck=_interopDefault(require("babel-runtime/helpers/newArrowCheck")),Fun=require("flow-static-land/lib/Fun"),utilsArray=require("@jumpn/utils-array"),_objectWithoutProperties=_interopDefault(require("babel-runtime/helpers/objectWithoutProperties")),_toConsumableArray=_interopDefault(require("babel-runtime/helpers/toConsumableArray")),_this$1=void 0,get=function(e,r){return _newArrowCheck(this,_this$1),r[e]}.bind(void 0),get$1=Fun.curry(get),_this$2=void 0,hasKey=function(e,r){return _newArrowCheck(this,_this$2),Object.prototype.hasOwnProperty.call(r,e)}.bind(void 0),hasKey$1=Fun.curry(hasKey),_this$3=void 0,objectRemove=function(e,r){r[e];var t=_objectWithoutProperties(r,[e]);return _newArrowCheck(this,_this$3),t}.bind(void 0),remove$1=function(e,r){return _newArrowCheck(this,_this$3),Array.isArray(r)?utilsArray.remove(e,1,r):objectRemove(e,r)}.bind(void 0),remove$2=Fun.curry(remove$1),_this$4=void 0,shallowCopy=function(e){return _newArrowCheck(this,_this$4),Array.isArray(e)?[].concat(_toConsumableArray(e)):_extends({},e)}.bind(void 0),_this=void 0,createReduceContext=function(e){_newArrowCheck(this,_this);var r=shallowCopy(e);return{origin:r,previous:void 0,current:r}}.bind(void 0),createSupporting=function(e){return _newArrowCheck(this,_this),"number"==typeof e?[]:{}}.bind(void 0),copyOrCreate=function(e,r,t){return _newArrowCheck(this,_this),hasKey$1(e,t)?shallowCopy(get$1(e,t)):createSupporting(r)}.bind(void 0),getNext=function(e,r,t,i){return _newArrowCheck(this,_this),utilsArray.isLastIndex(e,t)?r(get$1(e[t],i)):copyOrCreate(e[t],e[t+1],i)}.bind(void 0),set=function(e,r,t){return _newArrowCheck(this,_this),t[e]=r,get$1(e,t)}.bind(void 0),updateSet=function(e,r,t,i){return _newArrowCheck(this,_this),_extends({},i,{current:set(e[r],t,i.current)})}.bind(void 0),updateRemove=function(e,r,t){_newArrowCheck(this,_this);var i=remove$2(e[r],t.current);return 0===r?_extends({},t,{current:i,origin:i}):_extends({},t,{previous:set(e[r-1],i,t.previous)})}.bind(void 0),removeAction=_Symbol("composite.updateIn.removeAction"),update=function(e,r,t,i){return _newArrowCheck(this,_this),t===removeAction?updateRemove(e,r,i):updateSet(e,r,t,i)}.bind(void 0),getReducer=function(e,r){return _newArrowCheck(this,_this),function(t,i,n){return _newArrowCheck(this,_this),update(e,n,getNext(e,r,n,t.current),t)}.bind(this)}.bind(void 0),updateIn=function(e,r,t){return _newArrowCheck(this,_this),0===e.length?t:e.reduce(getReducer(e,r),createReduceContext(t)).origin}.bind(void 0),updateInCurried=Fun.curry(updateIn);updateInCurried.remove=removeAction,module.exports=updateInCurried; //# sourceMappingURL=updateIn.js.map