goliatone / gkeypath

Simple keypath module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make path character separator configurable

goliatone opened this issue · comments

Currently we use . as a path segment separator, we should make this optional.
Enable global override or a per-function override.

Use:

KeyPath.DEFAULTS = {
  separator: '.'
};

Keypath.get = function(target, path, defaultValue, options={}) {
        if (!target || !path) return false;

		let separator = options.separator || KeyPath.DEFAULTS.separator;

        path = path.split(separator);
...
};