Changelog
2.0.0 (2020-09-04)
This is a big major release with lots of improvements and some breaking changes. Please read the changes below and re-run your application tests after you upgrade to v2.
strict: boolean
class option that specifies whether to throw when a notation path does not exist on the source. (Note that #inspectGet()
and #inspectRemove()
methods are exceptions). It's recommended to set this to true
and prevent silent failures if you're working with sensitive data. Regardless of strict
option, it will always throw on invalid notation syntax or other crucial failures.restrictive: boolean
option for Notation
#filter()
instance method that specifies whether negated items strictly remove every match. Note that, regardless of this option; if any item has an exact negated version; non-negated is always removed. Default is false
. This option is also available for .normalize()
and .union()
static methods of Notation.Glob
class. For example; ['*', 'name', 'car.model', '!car.*']
will normalize to ['*', '!car.*', 'car.model']
. In restrictive
mode, it will normalize to ['*', '!car']
.Notation
.join()
static method for joining given notes into a notation string.Notation
.split()
static method for splitting given regular notation into a notes array.Notation.Glob
.split()
static method for splitting given glob notation into a notes array.Notation.Glob
#intersect()
instance method for checking whether current glob has any intersection with the given glob/notation.Notation.Glob
#covers()
instance method for checking whether given glob covers another specific glob.Notation#set()
method; instead of overwriting only.Notation
is a named export now. (Meaning require or import within curly brackets. e.g. const { Notation } = require('notation')
)prop1.prop2[3]
x[y]
, x.1
, x.y-z
, x.@
are incorrect and will never match.x["y"]
, x['1']
, x["y-z"]
, x["@"]
are correct.x.*
is valid (wildcard) for glob notation but invalid (object property) as regular notation.x[*]
is valid (wildcard) for glob notation but invalid (array index) as regular notation.x['*']
just indicates a property/key (star), not a wildcard. Valid regular notation.Notation.create([0, 1, 2]).remove('[1]').value
// will return [0, (empty), 2]
The empty item can be treated as undefined
in the sparse array result above. Set preserveIndices
option to false
to change this behavior.
const options = { preserveIndices: false };
Notation.create([0, 1, 2], options).remove('[1]').value
// will return [0, 2]
['!*.y', 'x']
would normalize as is but this had side-effects when union'ed with another glob list. Now it normalizes to ['x', '!x.y']
. Notice that in this example, intersection glob '!x.y'
is added and '!*.y'
is removed. See documentation for more.['*', '!x.*']
, the x
property would be completely removed. Now, x
will be emptied instead (i.e. {}
) due to explicit trailing wildcard star. To completely remove the x
property; filtering globs should be ['*', '!x']
.undefined
as the source object will now throw. This prevents accidental empty initialization. To initialize a Notation
instance with a new empty object, just omit the argument or explicitly define it. e.g. new Notation()
or new Notation({})
.#inspectGet()
method of Notation
class is renamed to #inspectGet()
for compatibility with Node.js version 10+. See DEP0079.Notation#eachKey()
(alias of #each()
) is removed. Now that bracket (and array) notation support is added, this name is misleading. (Now, "each" indicates each key and/or index.)Notation.Glob.normalize()
where it would throw RangeError: Maximum call stack size exceeded
when a glob list had both object and array notations for root level.Notatin.Glob.union()
where less restrictive globA
would be removed incorrectly when globB
had multiple trailing wildcards and both globs were negated.Notation.Glob.normalize()
where some redundant non-negated globs were not removed.Notation
throws an error, error instanceof Notation.Error
would return false
. Fixed.Thanks to @marcinkumorek and @BenoitRanque for their help.
Changelog
1.3.0 (2017-09-30)
Notation.Glob.normalize(array)
static method.Notation.Glob.toRegExp(glob)
static method.Notation.countNotes(notation)
convenience method.Notation.Glob.union()
static method. sort
(boolean
) argument is removed (the output is now always sorted.)!*.*.*
).Changelog
1.1.0 (2016-09-27)
Notation#expand()
method (alias Notation#aggregate()
).Notation#getFlat()
to Notation#flatten()
. Returns instance (chainable) instead of source.Notation#separate()
returns instance (chainable) instead of source.