UNPKG

@skele/classic

Version:

Skele is an architectural framework that assists with building data-driven apps with React or React Native.

1 lines 991 B
'use strict';Object.defineProperty(exports,"__esModule",{value:true});exports.parents=parents;exports.ancestors=ancestors;var _immutable=require("immutable");var _core=require("@skele/core");var _marked=regeneratorRuntime.mark(ancestors);var Cursor=_core.internal.Cursor;function parent(cursor){if(cursor==null){return null;}var root=cursor._rootData;var onChange=cursor._onChange;var keyPath=cursor._keyPath;if(keyPath.length===0){return null;}var newPath=keyPath.slice(0,-1);return Cursor.from(root,newPath,onChange);}function parents(cursor){if(cursor==null){return(0,_immutable.List)();}return(0,_immutable.Seq)(ancestors());}function ancestors(cursor){var current;return regeneratorRuntime.wrap(function ancestors$(_context){while(1){switch(_context.prev=_context.next){case 0:current=cursor;case 1:if(!(current!=null)){_context.next=7;break;}_context.next=4;return current;case 4:current=parent(current);_context.next=1;break;case 7:case"end":return _context.stop();}}},_marked,this);}