Repository navigation
See Migrating from 1.x for how to update.
Changed (breaking)
- Chaining is immutable. Every method returns a new query, so a chain that is never run can no longer leak into the next query. Calling methods one by one without using the return value no longer builds a query, and the
resetRecordoption and theoption/dataproperties are removed. getQuery()returns an ordered array of steps, and steps run in the order they were added. Queries in the 1.x object format are still accepted.innerJoinis a real inner join: items without a match are dropped, and an item with several matches appears once per match.wherewith several queries returns each matching item once, in input order.searchmatches the key literally instead of as a regular expression, skips missing fields, and is case sensitive unlesscaseSensitive: falseis passed.- Stricter, generic TypeScript types.
- The package is an ES module and requires Node.js 20.19 or later.
require("json-function")still works on those versions; on older ones it fails withERR_REQUIRE_ESM.
Removed
transformand the chain's.transform().
Added
leftJoin, with one row per match.selectreads dotted paths with{ deep: true }.- Documentation moved from GitBook into the repository (
docs/). Its examples are run by the tests.
Fixed
orderByno longer sorts the input array in place.searchno longer throws for keys such as"c++", and missing fields no longer match as"undefined".- Keys named
__proto__in data or inselect/schemaarguments can no longer change object prototypes orObject.prototype. - A saved query no longer drops steps or replays them in a different order.
Optimized
- Queries on large arrays are much faster: property paths,
where,search,selectandschemaare compiled once instead of per item,orderByreads each sort key once, and chains run filters and limits in one pass and select the top items fororderBy+limit. For example,searchon 200,000 items went from 65 ms to 4 ms.
Documentation: https://github.com/aykutkardas/Json-Function/tree/main/docs
Full changes: #35