@haxtheweb/haxcms-nodejs
Version:
HAXcms single and multisite nodejs server, api, and administration
10 lines • 1.52 kB
JavaScript
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import"./boot.js";export function isPath(t){return t.indexOf(".")>=0}export function root(t){let e=t.indexOf(".");return-1===e?t:t.slice(0,e)}export function isAncestor(t,e){return 0===t.indexOf(e+".")}export function isDescendant(t,e){return 0===e.indexOf(t+".")}export function translate(t,e,n){return e+n.slice(t.length)}export function matches(t,e){return t===e||isAncestor(t,e)||isDescendant(t,e)}export function normalize(t){if(Array.isArray(t)){let e=[];for(let n=0;n<t.length;n++){let r=t[n].toString().split(".");for(let t=0;t<r.length;t++)e.push(r[t])}return e.join(".")}return t}export function split(t){return Array.isArray(t)?normalize(t).split("."):t.toString().split(".")}export function get(t,e,n){let r=t,i=split(e);for(let t=0;t<i.length;t++){if(!r)return;r=r[i[t]]}return n&&(n.path=i.join(".")),r}export function set(t,e,n){let r=t,i=split(e),o=i[i.length-1];if(i.length>1){for(let t=0;t<i.length-1;t++){if(r=r[i[t]],!r)return}r[o]=n}else r[e]=n;return i.join(".")}export const isDeep=isPath;