Changelog
All notable changes to this project will be documented in this file.
See Conventional Commits for commit guidelines.
9.0.0
💥 BREAKING CHANGES
- Minimum supported Node version is v14.18; we’re dropping v12 support
8.1.0
✨ Features
- export types (11b5fb9)
8.0.16
🔧 Fixed
- correct the types (3ad3026)
- remove unused opts key and tweak regexes (3cf7a4c)
- tweak types (a890de1)
8.0.0
✨ Features
- migrate to ES Modules (8c9d95d)
💥 BREAKING CHANGES
- programs now are in ES Modules and won’t work with Common JS
require()
7.15.0
✨ Features
- config file based major bump blacklisting (e15f9bb)
7.14.0
✨ Features
- support undefined as a value within plain objects (6cdea34)
7.13.15
⏪ Reverts
- Revert “chore: setup refresh” (23cf206)
7.13.1
🔧 Fixed
- add
testStats
to npmignore (f3c84e9)
7.13.0
✨ Features
- rewrite in TS (136fc5f)
7.12.0
Accidental version bump during migration to SourceHut. Sorry about that.
7.11.0
✨ Features
- remove two dependencies and “info” mode which never worked (89c06f4)
7.10.0
- Various documentation and setup tweaks after we migrated to monorepo
- Setup refresh: updated dependencies and all config files using automated tools
7.6.0
- Updated all dependencies and restored coverage tracking both via terminal when testing and through coveralls.io
7.5.0
- Moved to BitBucket. GitHub sold us out.
- Removed Travis and BitHound (RIP), enabled Codacy (for code quality audit)
- Removed
package-lock
7.4.0
✨ Features
- Set up Prettier
- Removed
package.lock
and.editorconfig
- Wired Rollup to remove comments from non-dev builds. This means we can now leave the
console.log
s in the source code — Rollup will remove from production code.
7.3.0
✨ Features
- Updated to the latest release of
ast-monkey-traverse
(npm, GitLab) which gives theinnerObj.path
in the callback object. The path is exactly the same notation as per popular object-path and you can feedinnerObj.path
toobject-path
, you’d getcurrent
. However, this enables us to traverse up the tree, following the path. That’s the reason why I added this feature — to traverse the AST up to root when resolving variables in json-variables.
7.2.0
✈️ Changes
- Separated
traverse()
into a standalone library,ast-monkey-traverse
(npm, GitLab) and then tapped it
7.1.0
✨ Features
find()
anddel()
methods previously were using string-to-string comparisons. I replacedlodash.isequal
withast-compare
(npm, GitLab) running in strict mode with wildcards enabled. Now you can use matcher API when querying the keys or values.- Some rebasing done to improve the algorithm’s performance. For example,
find()
anddel()
previously matched the actual content first, then checkedopts.only
conditions. It was not effective because why perform a check ifopts.only
is not satisfied anyway? Now,opts.only
checks, is it of a desired type, and if so, continues to compare the values.
7.0.0
✈️ Changes
- The main source now is in ES2015 modules with
import
/export
. - Implemented Rollup to generate 3 flavours of this package: CommonJS, UMD and ESM
module
withimport
/export
.
6.4.0
🔧 Fixed
- 🔧 JS Standard and replaced it with raw ESLint on
airbnb-base
config, with override to ban semicolons.
6.3.0
🔧 Fixed
- 🔧 Removed
object-assign
and replaced it with ES6 nativeObject.assign
.
6.2.0
🔧 Fixed
- 🔧 Removed
monkey.existy()
from the exported methods list. It’s not used any more as checks are done stricly againstundefined
. Nownull
can be a valid value, as per JSON data types spec.
6.1.0
✨ Features
- Added checkTypes() onto drop(). Missed it this morning. Now all sorted.
6.0.0
BREAKING CHANGES
JSON spec allows objects to have null
in values. However, the traversal algotithm has not (until now) considered that. The key in an array would have val
reported as null
— same as (theoretical) object that has null
as key’s value.
This now changes.
Now, the absence of value will be marked with undefined
. Checking does a key/value pair have a value should be done checking if value is not undefined
.
This changes how you interact with traversal()
function. Sorry about this breaking change, but it’s part of my major drive to have all my libraries to support JSON spec. And in JSON, objects can have null
values.
✈️ Changes
- 🔧 Absence of value during traversal (as is the case when traversing arrays) is now marked as
undefined
. Previously it wasnull
. This will surely break all the algorithms that usemonkey.traverse()
. On a positive side, once you migrate your code toast-monkey
v6, you’ll be able to supportnull
in object key values, as per JSON spec.
✨ Features
opts.only
is now present on all relevantast-monkey
‘s methods and allows you to describe in natural language do you want to query only objects, or arrays or both. Previously it was only both. Supported values foropts.only
are quite wide:
// keywords for `opts.only` to query only objects:
[“object”, “objects”, “obj”, “ob”, “o”][
// keywords for `opts.only` to query only arrays:
(“array”, “arrays”, “arr”, “aray”, “arr”, “a”)
][
// keywords for `opts.only` to query both:
(“any”,
“all”,
“everything”,
“both”,
“either”,
“each”,
“whatever”,
“whatevs”,
“e”)
];
5.5.0
Hardened the API, namely, all added more validations to options object key values.
✨ Features
- Recoded all options objects’ validations, on each method. Preparing for next big secret feature. We’ll need this.
5.4.0
✨ Features
- Holes in arrays were skipped in
traverse()
as if they didn’t exist. Now I push it further,traverse()
will silently delete any holes in arrays it encounters. I think this feature a no-brainer since array holes have no use in JS.
5.3.0
✨ Features
- Set
standard
to be consumer under normal semver range, not the latest in order to prevent surprises in the future. Which happened as late as v10.
5.2.0
✨ Features
- Tighetened the API in cases when
monkey()
inputs are missing or falsey.
5.1.0
✨ Features
innerObj.parent
totraverse()
. Now you can query sibling elements. I needed this forjson-variables
(npm, GitLab) to allow variables lookup at deeper levels, not only at the root. 🦄
5.0.0
After spending nearly whole Sunday testing [v4], I discovered that passing undefined
as an instruction to delete is wrong, because how do you pass the message that the current item is an array? Previously, when there were no null
values allowed, null in the value meant array, but also, when received as a result of traverse()
it meant an instruction to delete. Now we can’t touch null
because it’s a legitimate value! So we switched to undefined
. But we can’t use it for both as an instruction to delete AND as a marker of an array, because that way we will not be able to delete from arrays.
✈️ Changes
- 🔧 Internally, the message to delete in
traverse()
is nowNaN
.
🔧 Fixed
- 🔧 All the methods stay the same. I just rewired all internal messaging to use
NaN
instead ofundefined
as an instruction fortraverse()
to delete.
4.0.0
The good thing about being not popular is you can make breaking changes and very few (if anybody) will care. I will make use of this privilege and do some cardinal yet necessary API changes.
✈️ Changes
- 🔧 Removing options from
traverse()
. It’s not necessary any more. See below why. - 🔧 When particular node is to be deleted, the message (function’s
return
value) previously wasnull
. This is not effective as JSON objects can havenull
values and this meansmonkey.traverse()
does not know, is it valuenull
being returned recursively, or is it an instruction coming from deeper resursions to delete current thing. That’s why I decided to move ontoundefined
as a deletion message — it can’t be a JSON value, and it does not belong among the object values — it’s perfect format for a deletion message.
🔧 Fixed
- 🔧 All the methods stay the same. I just rewired all internal messaging to use
undefined
instead ofnull
as an instruction fortraverse()
to delete.
3.3.0
✨ Features
🐒.traverse()
gets options! ✨ Optionalopts.nullDeletes===false
now let’s you to writenull
values during traversal. Previously on all cases (and currently during defaultopts.nullDeletes===true
)null
would be interpreted as an instruction to delete the current piece of AST. Now you can essentially turn off the deletion in favor of being able to writenull
as value. For the record,null
is a valid JSON value type. 🦄
3.2.0
✨ Features
- Imagine, you’re using
🐒.traverse()
(ast-monkey on npm/ast-monkey on GitLab) on the following piece of AST:
{
title: [‘something’, ‘anything’],
title_data: {
subtitle: ‘text’,
submarine: ‘ship’
}
}
When you’ll be traversing the array, [‘something’, ‘anything’]
, you’ll have access to the key name, title
, via innerObj.topmostKey
on the callback. ✨
I needed this feature for json-variables
(npm, GitLab) where I wanted to access title_data
key, same-named key except with appended string, at the same level as parent. This does not affect any unit tests, it’s a handy extra information piece which was always there, only just now tapped. 👍
3.1.0 (2017-04-01) International Fools day No tricks here though
🏗️ Improvements
- 🔧 All this Saturday morning I worked on
🐒.traverse()
. Yesterday night I discovered that when you delete something ontraverse()
, the traversal reports extra non-existing nodes. The solution is not so elementary. Yes, the iterator was not being reduced in thefor
loop —i--
was missing — but there were also more fixes necessary to implement for this to work. Now when you want to instructtraverse()
to delete current node, you have to passnull
(undefined
won’t work). I believe that’s how everybody were using it anyway, so it doesn’t warrant major semver bump. ✨
✨ Features
- Added
traverse()
unit tests, namely,09.x
group.
🔧 Fixed
- Unit test coverage stays solid 100% lines.
3.0.0
✈️ Changes
BREAKING API CHANGES.
- 🔧
flatten()
method renamed toarrayFirstOnly()
to reflect better what this does. The real “flatten” is object-flatten-all-arrays and while it could be rewritten inast-monkey
, it goes against the overall flow of theast-monkey
‘s algorithm — 🐒 goes horizontal, by branch, whileflatten-all-arrays
goes vertically, by array, all keys at once. The newarrayFirstOnly()
is easy feature because it simply filters the first element of each array encountered during the traversal.
✨ Features
- Exposed
.traverse()
too; shielded its inner API with another function (one input arguement-less now)
2.9.0 (2017-03-09) International recursive alrorithms day
✨ Features
.flatten()
- related unit tests.
✈️ Changes
.info()
now returns the input, notundefined
. This doesn’t warrant major version bump because method was for logging only and nothing changes in this aspect.
2.8.0
✨ Features
- Now cloning all arguments in main
🐒()
and auxiliarytraverse()
functions’ input object args to prevent any accidental mutation. This is big and very important.
2.7.0
🔧 Fixed
- Replaced spread operator with lodash equivalent to avoid unnecessary Babel use 😌
2.6.0 (2017-02-19) Actual day of NTFS invention
✨ Features
- Incoming input is cloned upon receiving and clone is used instead, so that original input is not mutated. This is very important. ✨
2.5.0
✨ Features
- Rebased the requirements for
opts.key
oropts.val
to exist, nowfind()
anddel()
are combined.
2.4.0
✨ Features
- Enforcing the {index: ?} to be provided for
drop()
. ✨
2.3.0
✨ Features
- Added
index
key to each offind()
result object. 👌
2.2.0 (2017-02-16) International software testers commemoration day
✨ Features
- Added
del()
method which deletes pieces from AST’s by key or by value or by both. It leaves empty stumps and does not clean after deletion.
2.0.0
✈️ Changes
- 🔧 Major API change. Initial release’s
get()
didn’t make sense. It was returning a “synthetic” object with a separate keys containing info about fetched piece of AST, not the piece itself. This meant, it was not possible to actually get the whole intact piece! Now, I am simply returning the whole finding fromget()
. That’s it. 😌