Skip to content

Releases: aykutkardas/json-function

v2.0.0

Choose a tag to compare

@aykutkardas aykutkardas released this 03 Oct 20:57

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 resetRecord option and the option/data properties 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.
  • innerJoin is a real inner join: items without a match are dropped, and an item with several matches appears once per match.
  • where with several queries returns each matching item once, in input order.
  • search matches the key literally instead of as a regular expression, skips missing fields, and is case sensitive unless caseSensitive: false is 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 with ERR_REQUIRE_ESM.

Removed

  • transform and the chain's .transform().

Added

  • leftJoin, with one row per match.
  • select reads dotted paths with { deep: true }.
  • Documentation moved from GitBook into the repository (docs/). Its examples are run by the tests.

Fixed

  • orderBy no longer sorts the input array in place.
  • search no longer throws for keys such as "c++", and missing fields no longer match as "undefined".
  • Keys named __proto__ in data or in select/schema arguments can no longer change object prototypes or Object.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, select and schema are compiled once instead of per item, orderBy reads each sort key once, and chains run filters and limits in one pass and select the top items for orderBy + limit. For example, search on 200,000 items went from 65 ms to 4 ms.

Documentation: https://github.com/aykutkardas/Json-Function/tree/main/docs
Full changes: #35

v1.8.40

Choose a tag to compare

@aykutkardas aykutkardas released this 03 Oct 20:57

Security fixes for the 1.x line. Published on npm with the legacy tag; latest is 2.x. Install it with npm install json-function@legacy.

Fixed

  • search passed the key to RegExp unescaped. A key such as "(" threw, and a pattern such as "(a+)+$" could hang the process (ReDoS). The key is now matched as plain text, as documented.
  • transform converted a key such as "____proto____" to "__proto__" and assigned it, so JSON input could replace the prototype of the returned object. The key is now kept as an own property.

Code that relied on search treating the key as a regular expression gets plain-text matching instead. This behavior was never documented.

Both issues are also fixed in 2.0.0.

Full changes: #36

v1.8.35

Choose a tag to compare

@aykutkardas aykutkardas released this 23 May 00:21
  • TypeScript support updated. 🔥
  • General refactoring and optimization.🔧
  • InnerJoin method is now x5 faster. 🚀

v1.8.16

Choose a tag to compare

@aykutkardas aykutkardas released this 14 Mar 21:31
  • Merge pull request #6 from aykutkardas/dependabot/npm_and_yarn/acorn-6.4.1 dbee1c3
  • Bump acorn from 6.0.4 to 6.4.1 ae8d023

v1.8.15...v1.8.16

v1.8.15

Choose a tag to compare

@aykutkardas aykutkardas released this 14 Mar 21:29
  • Search method caseSensitive control update. e327887
  • Added "search" method to Readme. e6817bb
  • Search method added. 0c1d3f2
  • Update @types/* modules. 54a9542
  • CloneDeep utils refactor. e924386
  • Added isNull on type-check utils. 8b9eb3d

v1.8.14...v1.8.15

v1.8.4

Choose a tag to compare

@aykutkardas aykutkardas released this 08 Aug 21:54
  • isFunction method added to type-check methods. 183a2a7
  • toArray method argument control problem solved. c48f388

v1.8.3...v1.8.4

v1.8.3

Choose a tag to compare

@aykutkardas aykutkardas released this 08 Aug 21:27
  • TypeCheck methods problem fixed. 6711b88

v1.8.2...v1.8.3

v1.8.2

Choose a tag to compare

@aykutkardas aykutkardas released this 07 Jul 13:53

v1.6.1...v1.8.2

v1.8.1

Choose a tag to compare

@aykutkardas aykutkardas released this 19 Mar 20:15
v1.8.1

v1.6.1

Choose a tag to compare

@aykutkardas aykutkardas released this 10 Mar 13:40
  • Code refactor and optimization. Remove schema fields array and schemaToolGenerator move to seperate file . 46ac561

v1.6.0...v1.6.1