some progress

This commit is contained in:
Jonas_Jones 2023-03-30 20:40:42 +02:00
parent aea93a5527
commit e3c15bd288
1388 changed files with 306946 additions and 68323 deletions

9
node_modules/mpath/.travis.yml generated vendored Normal file
View file

@ -0,0 +1,9 @@
language: node_js
node_js:
- "4"
- "5"
- "6"
- "7"
- "8"
- "9"
- "10"

88
node_modules/mpath/History.md generated vendored Normal file
View file

@ -0,0 +1,88 @@
0.9.0 / 2022-04-17
==================
* feat: export `stringToParts()`
0.8.4 / 2021-09-01
==================
* fix: throw error if `parts` contains an element that isn't a string or number #13
0.8.3 / 2020-12-30
==================
* fix: use var instead of let/const for Node.js 4.x support
0.8.2 / 2020-12-30
==================
* fix(stringToParts): fall back to legacy treatment for square brackets if square brackets contents aren't a number Automattic/mongoose#9640
* chore: add eslint
0.8.1 / 2020-12-10
==================
* fix(stringToParts): handle empty string and trailing dot the same way that `split()` does for backwards compat
0.8.0 / 2020-11-14
==================
* feat: support square bracket indexing for `get()`, `set()`, `has()`, and `unset()`
0.7.0 / 2020-03-24
==================
* BREAKING CHANGE: remove `component.json` #9 [AlexeyGrigorievBoost](https://github.com/AlexeyGrigorievBoost)
0.6.0 / 2019-05-01
==================
* feat: support setting dotted paths within nested arrays
0.5.2 / 2019-04-25
==================
* fix: avoid using subclassed array constructor when doing `map()`
0.5.1 / 2018-08-30
==================
* fix: prevent writing to constructor and prototype as well as __proto__
0.5.0 / 2018-08-30
==================
* BREAKING CHANGE: disallow setting/unsetting __proto__ properties
* feat: re-add support for Node < 4 for this release
0.4.1 / 2018-04-08
==================
* fix: allow opting out of weird `$` set behavior re: Automattic/mongoose#6273
0.4.0 / 2018-03-27
==================
* feat: add support for ES6 maps
* BREAKING CHANGE: drop support for Node < 4
0.3.0 / 2017-06-05
==================
* feat: add has() and unset() functions
0.2.1 / 2013-03-22
==================
* test; added for #5
* fix typo that breaks set #5 [Contra](https://github.com/Contra)
0.2.0 / 2013-03-15
==================
* added; adapter support for set
* added; adapter support for get
* add basic benchmarks
* add support for using module as a component #2 [Contra](https://github.com/Contra)
0.1.1 / 2012-12-21
==================
* added; map support
0.1.0 / 2012-12-13
==================
* added; set('array.property', val, object) support
* added; get('array.property', object) support
0.0.1 / 2012-11-03
==================
* initial release

22
node_modules/mpath/LICENSE generated vendored Normal file
View file

@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2012 [Aaron Heckmann](aaron.heckmann+github@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

278
node_modules/mpath/README.md generated vendored Normal file
View file

@ -0,0 +1,278 @@
#mpath
{G,S}et javascript object values using MongoDB-like path notation.
###Getting
```js
var mpath = require('mpath');
var obj = {
comments: [
{ title: 'funny' },
{ title: 'exciting!' }
]
}
mpath.get('comments.1.title', obj) // 'exciting!'
```
`mpath.get` supports array property notation as well.
```js
var obj = {
comments: [
{ title: 'funny' },
{ title: 'exciting!' }
]
}
mpath.get('comments.title', obj) // ['funny', 'exciting!']
```
Array property and indexing syntax, when used together, are very powerful.
```js
var obj = {
array: [
{ o: { array: [{x: {b: [4,6,8]}}, { y: 10} ] }}
, { o: { array: [{x: {b: [1,2,3]}}, { x: {z: 10 }}, { x: 'Turkey Day' }] }}
, { o: { array: [{x: {b: null }}, { x: { b: [null, 1]}}] }}
, { o: { array: [{x: null }] }}
, { o: { array: [{y: 3 }] }}
, { o: { array: [3, 0, null] }}
, { o: { name: 'ha' }}
];
}
var found = mpath.get('array.o.array.x.b.1', obj);
console.log(found); // prints..
[ [6, undefined]
, [2, undefined, undefined]
, [null, 1]
, [null]
, [undefined]
, [undefined, undefined, undefined]
, undefined
]
```
#####Field selection rules:
The following rules are iteratively applied to each `segment` in the passed `path`. For example:
```js
var path = 'one.two.14'; // path
'one' // segment 0
'two' // segment 1
14 // segment 2
```
- 1) when value of the segment parent is not an array, return the value of `parent.segment`
- 2) when value of the segment parent is an array
- a) if the segment is an integer, replace the parent array with the value at `parent[segment]`
- b) if not an integer, keep the array but replace each array `item` with the value returned from calling `get(remainingSegments, item)` or undefined if falsey.
#####Maps
`mpath.get` also accepts an optional `map` argument which receives each individual found value. The value returned from the `map` function will be used in the original found values place.
```js
var obj = {
comments: [
{ title: 'funny' },
{ title: 'exciting!' }
]
}
mpath.get('comments.title', obj, function (val) {
return 'funny' == val
? 'amusing'
: val;
});
// ['amusing', 'exciting!']
```
###Setting
```js
var obj = {
comments: [
{ title: 'funny' },
{ title: 'exciting!' }
]
}
mpath.set('comments.1.title', 'hilarious', obj)
console.log(obj.comments[1].title) // 'hilarious'
```
`mpath.set` supports the same array property notation as `mpath.get`.
```js
var obj = {
comments: [
{ title: 'funny' },
{ title: 'exciting!' }
]
}
mpath.set('comments.title', ['hilarious', 'fruity'], obj);
console.log(obj); // prints..
{ comments: [
{ title: 'hilarious' },
{ title: 'fruity' }
]}
```
Array property and indexing syntax can be used together also when setting.
```js
var obj = {
array: [
{ o: { array: [{x: {b: [4,6,8]}}, { y: 10} ] }}
, { o: { array: [{x: {b: [1,2,3]}}, { x: {z: 10 }}, { x: 'Turkey Day' }] }}
, { o: { array: [{x: {b: null }}, { x: { b: [null, 1]}}] }}
, { o: { array: [{x: null }] }}
, { o: { array: [{y: 3 }] }}
, { o: { array: [3, 0, null] }}
, { o: { name: 'ha' }}
]
}
mpath.set('array.1.o', 'this was changed', obj);
console.log(require('util').inspect(obj, false, 1000)); // prints..
{
array: [
{ o: { array: [{x: {b: [4,6,8]}}, { y: 10} ] }}
, { o: 'this was changed' }
, { o: { array: [{x: {b: null }}, { x: { b: [null, 1]}}] }}
, { o: { array: [{x: null }] }}
, { o: { array: [{y: 3 }] }}
, { o: { array: [3, 0, null] }}
, { o: { name: 'ha' }}
];
}
mpath.set('array.o.array.x', 'this was changed too', obj);
console.log(require('util').inspect(obj, false, 1000)); // prints..
{
array: [
{ o: { array: [{x: 'this was changed too'}, { y: 10, x: 'this was changed too'} ] }}
, { o: 'this was changed' }
, { o: { array: [{x: 'this was changed too'}, { x: 'this was changed too'}] }}
, { o: { array: [{x: 'this was changed too'}] }}
, { o: { array: [{x: 'this was changed too', y: 3 }] }}
, { o: { array: [3, 0, null] }}
, { o: { name: 'ha' }}
];
}
```
####Setting arrays
By default, setting a property within an array to another array results in each element of the new array being set to the item in the destination array at the matching index. An example is helpful.
```js
var obj = {
comments: [
{ title: 'funny' },
{ title: 'exciting!' }
]
}
mpath.set('comments.title', ['hilarious', 'fruity'], obj);
console.log(obj); // prints..
{ comments: [
{ title: 'hilarious' },
{ title: 'fruity' }
]}
```
If we do not desire this destructuring-like assignment behavior we may instead specify the `$` operator in the path being set to force the array to be copied directly.
```js
var obj = {
comments: [
{ title: 'funny' },
{ title: 'exciting!' }
]
}
mpath.set('comments.$.title', ['hilarious', 'fruity'], obj);
console.log(obj); // prints..
{ comments: [
{ title: ['hilarious', 'fruity'] },
{ title: ['hilarious', 'fruity'] }
]}
```
####Field assignment rules
The rules utilized mirror those used on `mpath.get`, meaning we can take values returned from `mpath.get`, update them, and reassign them using `mpath.set`. Note that setting nested arrays of arrays can get unweildy quickly. Check out the [tests](https://github.com/aheckmann/mpath/blob/master/test/index.js) for more extreme examples.
#####Maps
`mpath.set` also accepts an optional `map` argument which receives each individual value being set. The value returned from the `map` function will be used in the original values place.
```js
var obj = {
comments: [
{ title: 'funny' },
{ title: 'exciting!' }
]
}
mpath.set('comments.title', ['hilarious', 'fruity'], obj, function (val) {
return val.length;
});
console.log(obj); // prints..
{ comments: [
{ title: 9 },
{ title: 6 }
]}
```
### Custom object types
Sometimes you may want to enact the same functionality on custom object types that store all their real data internally, say for an ODM type object. No fear, `mpath` has you covered. Simply pass the name of the property being used to store the internal data and it will be traversed instead:
```js
var mpath = require('mpath');
var obj = {
comments: [
{ title: 'exciting!', _doc: { title: 'great!' }}
]
}
mpath.get('comments.0.title', obj, '_doc') // 'great!'
mpath.set('comments.0.title', 'nov 3rd', obj, '_doc')
mpath.get('comments.0.title', obj, '_doc') // 'nov 3rd'
mpath.get('comments.0.title', obj) // 'exciting'
```
When used with a `map`, the `map` argument comes last.
```js
mpath.get(path, obj, '_doc', map);
mpath.set(path, val, obj, '_doc', map);
```
[LICENSE](https://github.com/aheckmann/mpath/blob/master/LICENSE)

5
node_modules/mpath/SECURITY.md generated vendored Normal file
View file

@ -0,0 +1,5 @@
# Reporting a Vulnerability
Please report suspected security vulnerabilities to val [at] karpov [dot] io.
You will receive a response from us within 72 hours.
If the issue is confirmed, we will release a patch as soon as possible depending on complexity.

3
node_modules/mpath/index.js generated vendored Normal file
View file

@ -0,0 +1,3 @@
'use strict';
module.exports = exports = require('./lib');

336
node_modules/mpath/lib/index.js generated vendored Normal file
View file

@ -0,0 +1,336 @@
/* eslint strict:off */
/* eslint no-var: off */
/* eslint no-redeclare: off */
var stringToParts = require('./stringToParts');
// These properties are special and can open client libraries to security
// issues
var ignoreProperties = ['__proto__', 'constructor', 'prototype'];
/**
* Returns the value of object `o` at the given `path`.
*
* ####Example:
*
* var obj = {
* comments: [
* { title: 'exciting!', _doc: { title: 'great!' }}
* , { title: 'number dos' }
* ]
* }
*
* mpath.get('comments.0.title', o) // 'exciting!'
* mpath.get('comments.0.title', o, '_doc') // 'great!'
* mpath.get('comments.title', o) // ['exciting!', 'number dos']
*
* // summary
* mpath.get(path, o)
* mpath.get(path, o, special)
* mpath.get(path, o, map)
* mpath.get(path, o, special, map)
*
* @param {String} path
* @param {Object} o
* @param {String} [special] When this property name is present on any object in the path, walking will continue on the value of this property.
* @param {Function} [map] Optional function which receives each individual found value. The value returned from `map` is used in the original values place.
*/
exports.get = function(path, o, special, map) {
var lookup;
if ('function' == typeof special) {
if (special.length < 2) {
map = special;
special = undefined;
} else {
lookup = special;
special = undefined;
}
}
map || (map = K);
var parts = 'string' == typeof path
? stringToParts(path)
: path;
if (!Array.isArray(parts)) {
throw new TypeError('Invalid `path`. Must be either string or array');
}
var obj = o,
part;
for (var i = 0; i < parts.length; ++i) {
part = parts[i];
if (typeof parts[i] !== 'string' && typeof parts[i] !== 'number') {
throw new TypeError('Each segment of path to `get()` must be a string or number, got ' + typeof parts[i]);
}
if (Array.isArray(obj) && !/^\d+$/.test(part)) {
// reading a property from the array items
var paths = parts.slice(i);
// Need to `concat()` to avoid `map()` calling a constructor of an array
// subclass
return [].concat(obj).map(function(item) {
return item
? exports.get(paths, item, special || lookup, map)
: map(undefined);
});
}
if (lookup) {
obj = lookup(obj, part);
} else {
var _from = special && obj[special] ? obj[special] : obj;
obj = _from instanceof Map ?
_from.get(part) :
_from[part];
}
if (!obj) return map(obj);
}
return map(obj);
};
/**
* Returns true if `in` returns true for every piece of the path
*
* @param {String} path
* @param {Object} o
*/
exports.has = function(path, o) {
var parts = typeof path === 'string' ?
stringToParts(path) :
path;
if (!Array.isArray(parts)) {
throw new TypeError('Invalid `path`. Must be either string or array');
}
var len = parts.length;
var cur = o;
for (var i = 0; i < len; ++i) {
if (typeof parts[i] !== 'string' && typeof parts[i] !== 'number') {
throw new TypeError('Each segment of path to `has()` must be a string or number, got ' + typeof parts[i]);
}
if (cur == null || typeof cur !== 'object' || !(parts[i] in cur)) {
return false;
}
cur = cur[parts[i]];
}
return true;
};
/**
* Deletes the last piece of `path`
*
* @param {String} path
* @param {Object} o
*/
exports.unset = function(path, o) {
var parts = typeof path === 'string' ?
stringToParts(path) :
path;
if (!Array.isArray(parts)) {
throw new TypeError('Invalid `path`. Must be either string or array');
}
var len = parts.length;
var cur = o;
for (var i = 0; i < len; ++i) {
if (cur == null || typeof cur !== 'object' || !(parts[i] in cur)) {
return false;
}
if (typeof parts[i] !== 'string' && typeof parts[i] !== 'number') {
throw new TypeError('Each segment of path to `unset()` must be a string or number, got ' + typeof parts[i]);
}
// Disallow any updates to __proto__ or special properties.
if (ignoreProperties.indexOf(parts[i]) !== -1) {
return false;
}
if (i === len - 1) {
delete cur[parts[i]];
return true;
}
cur = cur instanceof Map ? cur.get(parts[i]) : cur[parts[i]];
}
return true;
};
/**
* Sets the `val` at the given `path` of object `o`.
*
* @param {String} path
* @param {Anything} val
* @param {Object} o
* @param {String} [special] When this property name is present on any object in the path, walking will continue on the value of this property.
* @param {Function} [map] Optional function which is passed each individual value before setting it. The value returned from `map` is used in the original values place.
*/
exports.set = function(path, val, o, special, map, _copying) {
var lookup;
if ('function' == typeof special) {
if (special.length < 2) {
map = special;
special = undefined;
} else {
lookup = special;
special = undefined;
}
}
map || (map = K);
var parts = 'string' == typeof path
? stringToParts(path)
: path;
if (!Array.isArray(parts)) {
throw new TypeError('Invalid `path`. Must be either string or array');
}
if (null == o) return;
for (var i = 0; i < parts.length; ++i) {
if (typeof parts[i] !== 'string' && typeof parts[i] !== 'number') {
throw new TypeError('Each segment of path to `set()` must be a string or number, got ' + typeof parts[i]);
}
// Silently ignore any updates to `__proto__`, these are potentially
// dangerous if using mpath with unsanitized data.
if (ignoreProperties.indexOf(parts[i]) !== -1) {
return;
}
}
// the existance of $ in a path tells us if the user desires
// the copying of an array instead of setting each value of
// the array to the one by one to matching positions of the
// current array. Unless the user explicitly opted out by passing
// false, see Automattic/mongoose#6273
var copy = _copying || (/\$/.test(path) && _copying !== false),
obj = o,
part;
for (var i = 0, len = parts.length - 1; i < len; ++i) {
part = parts[i];
if ('$' == part) {
if (i == len - 1) {
break;
} else {
continue;
}
}
if (Array.isArray(obj) && !/^\d+$/.test(part)) {
var paths = parts.slice(i);
if (!copy && Array.isArray(val)) {
for (var j = 0; j < obj.length && j < val.length; ++j) {
// assignment of single values of array
exports.set(paths, val[j], obj[j], special || lookup, map, copy);
}
} else {
for (var j = 0; j < obj.length; ++j) {
// assignment of entire value
exports.set(paths, val, obj[j], special || lookup, map, copy);
}
}
return;
}
if (lookup) {
obj = lookup(obj, part);
} else {
var _to = special && obj[special] ? obj[special] : obj;
obj = _to instanceof Map ?
_to.get(part) :
_to[part];
}
if (!obj) return;
}
// process the last property of the path
part = parts[len];
// use the special property if exists
if (special && obj[special]) {
obj = obj[special];
}
// set the value on the last branch
if (Array.isArray(obj) && !/^\d+$/.test(part)) {
if (!copy && Array.isArray(val)) {
_setArray(obj, val, part, lookup, special, map);
} else {
for (var j = 0; j < obj.length; ++j) {
var item = obj[j];
if (item) {
if (lookup) {
lookup(item, part, map(val));
} else {
if (item[special]) item = item[special];
item[part] = map(val);
}
}
}
}
} else {
if (lookup) {
lookup(obj, part, map(val));
} else if (obj instanceof Map) {
obj.set(part, map(val));
} else {
obj[part] = map(val);
}
}
};
/*!
* Split a string path into components delimited by '.' or
* '[\d+]'
*
* #### Example:
* stringToParts('foo[0].bar.1'); // ['foo', '0', 'bar', '1']
*/
exports.stringToParts = stringToParts;
/*!
* Recursively set nested arrays
*/
function _setArray(obj, val, part, lookup, special, map) {
for (var item, j = 0; j < obj.length && j < val.length; ++j) {
item = obj[j];
if (Array.isArray(item) && Array.isArray(val[j])) {
_setArray(item, val[j], part, lookup, special, map);
} else if (item) {
if (lookup) {
lookup(item, part, map(val[j]));
} else {
if (item[special]) item = item[special];
item[part] = map(val[j]);
}
}
}
}
/*!
* Returns the value passed to it.
*/
function K(v) {
return v;
}

48
node_modules/mpath/lib/stringToParts.js generated vendored Normal file
View file

@ -0,0 +1,48 @@
'use strict';
module.exports = function stringToParts(str) {
const result = [];
let curPropertyName = '';
let state = 'DEFAULT';
for (let i = 0; i < str.length; ++i) {
// Fall back to treating as property name rather than bracket notation if
// square brackets contains something other than a number.
if (state === 'IN_SQUARE_BRACKETS' && !/\d/.test(str[i]) && str[i] !== ']') {
state = 'DEFAULT';
curPropertyName = result[result.length - 1] + '[' + curPropertyName;
result.splice(result.length - 1, 1);
}
if (str[i] === '[') {
if (state !== 'IMMEDIATELY_AFTER_SQUARE_BRACKETS') {
result.push(curPropertyName);
curPropertyName = '';
}
state = 'IN_SQUARE_BRACKETS';
} else if (str[i] === ']') {
if (state === 'IN_SQUARE_BRACKETS') {
state = 'IMMEDIATELY_AFTER_SQUARE_BRACKETS';
result.push(curPropertyName);
curPropertyName = '';
} else {
state = 'DEFAULT';
curPropertyName += str[i];
}
} else if (str[i] === '.') {
if (state !== 'IMMEDIATELY_AFTER_SQUARE_BRACKETS') {
result.push(curPropertyName);
curPropertyName = '';
}
state = 'DEFAULT';
} else {
curPropertyName += str[i];
}
}
if (state !== 'IMMEDIATELY_AFTER_SQUARE_BRACKETS') {
result.push(curPropertyName);
}
return result;
};

144
node_modules/mpath/package.json generated vendored Normal file
View file

@ -0,0 +1,144 @@
{
"name": "mpath",
"version": "0.9.0",
"description": "{G,S}et object values using MongoDB-like path notation",
"main": "index.js",
"scripts": {
"lint": "eslint .",
"test": "mocha test/*"
},
"engines": {
"node": ">=4.0.0"
},
"repository": "git://github.com/aheckmann/mpath.git",
"keywords": [
"mongodb",
"path",
"get",
"set"
],
"author": "Aaron Heckmann <aaron.heckmann+github@gmail.com>",
"license": "MIT",
"devDependencies": {
"mocha": "5.x",
"benchmark": "~1.0.0",
"eslint": "7.16.0"
},
"eslintConfig": {
"extends": [
"eslint:recommended"
],
"parserOptions": {
"ecmaVersion": 2015
},
"env": {
"node": true,
"es6": true
},
"rules": {
"comma-style": "error",
"indent": [
"error",
2,
{
"SwitchCase": 1,
"VariableDeclarator": 2
}
],
"keyword-spacing": "error",
"no-whitespace-before-property": "error",
"no-buffer-constructor": "warn",
"no-console": "off",
"no-multi-spaces": "error",
"no-constant-condition": "off",
"func-call-spacing": "error",
"no-trailing-spaces": "error",
"no-undef": "error",
"no-unneeded-ternary": "error",
"no-const-assign": "error",
"no-useless-rename": "error",
"no-dupe-keys": "error",
"space-in-parens": [
"error",
"never"
],
"spaced-comment": [
"error",
"always",
{
"block": {
"markers": [
"!"
],
"balanced": true
}
}
],
"key-spacing": [
"error",
{
"beforeColon": false,
"afterColon": true
}
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"array-bracket-spacing": 1,
"arrow-spacing": [
"error",
{
"before": true,
"after": true
}
],
"object-curly-spacing": [
"error",
"always"
],
"comma-dangle": [
"error",
"never"
],
"no-unreachable": "error",
"quotes": [
"error",
"single"
],
"quote-props": [
"error",
"as-needed"
],
"semi": "error",
"no-extra-semi": "error",
"semi-spacing": "error",
"no-spaced-func": "error",
"no-throw-literal": "error",
"space-before-blocks": "error",
"space-before-function-paren": [
"error",
"never"
],
"space-infix-ops": "error",
"space-unary-ops": "error",
"no-var": "warn",
"prefer-const": "warn",
"strict": [
"error",
"global"
],
"no-restricted-globals": [
"error",
{
"name": "context",
"message": "Don't use Mocha's global context"
}
],
"no-prototype-builtins": "off"
}
}
}

4
node_modules/mpath/test/.eslintrc.yml generated vendored Normal file
View file

@ -0,0 +1,4 @@
env:
mocha: true
rules:
no-unused-vars: off

1879
node_modules/mpath/test/index.js generated vendored Normal file

File diff suppressed because it is too large Load diff

30
node_modules/mpath/test/stringToParts.js generated vendored Normal file
View file

@ -0,0 +1,30 @@
'use strict';
const assert = require('assert');
const stringToParts = require('../lib/stringToParts');
describe('stringToParts', function() {
it('handles brackets for numbers', function() {
assert.deepEqual(stringToParts('list[0].name'), ['list', '0', 'name']);
assert.deepEqual(stringToParts('list[0][1].name'), ['list', '0', '1', 'name']);
});
it('handles dot notation', function() {
assert.deepEqual(stringToParts('a.b.c'), ['a', 'b', 'c']);
assert.deepEqual(stringToParts('a..b.d'), ['a', '', 'b', 'd']);
});
it('ignores invalid numbers in square brackets', function() {
assert.deepEqual(stringToParts('foo[1mystring]'), ['foo[1mystring]']);
assert.deepEqual(stringToParts('foo[1mystring].bar[1]'), ['foo[1mystring]', 'bar', '1']);
assert.deepEqual(stringToParts('foo[1mystring][2]'), ['foo[1mystring]', '2']);
});
it('handles empty string', function() {
assert.deepEqual(stringToParts(''), ['']);
});
it('handles trailing dot', function() {
assert.deepEqual(stringToParts('a.b.'), ['a', 'b', '']);
});
});