split-keypath
Version:
Splits strings into an array of keys used for reading nested data structures
8 lines • 1.24 kB
JavaScript
/*! split-keypath v1.0.1 - Wed Mar 23 2016 12:13:09 AM. (c) 2016 Miguel Castillo. Licensed under MIT */
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.splitKeypath=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){/**
* Method that converts a string of object and array keys, which we also
* refer to as keypath, to an array of keys that can be used for reading
* nested values in an object.
*/
function d(a){for(var b,c=/(\w+)|\[([^\]]+)\]/g,d=[];b=c.exec(a||"");)"["===a[b.index]?d.push(b[2]):d.push(b[1]);return d}b.exports=d},{}]},{},[1])(1)});
//# sourceMappingURL=index.min.js.map