- feat: add an optional
ownOnlyargument togetByKeyPath()andsetAtKeyPath() - fix: enable own-only traversal for type revival and cyclic-reference metadata
- fix: Crafted
#__proto__and#constructorreferences no longer expose built-in objects
- fix(security): avoid potential to set nested proto
- fix: revival metadata lookup now accepts only own
$typesentries, avoiding inheritedObject.prototypebeing mistaken for type metadata. - fix:
catch()now delegates withthis.then(undefined, onRejected), preserving fulfilled values while handling only rejections. - fix:
specialTypeNames()androotTypeName()now copy caller options before adding their internal flags, leaving the supplied objects unchanged - fix: re-registering a type now removes its previous replacer from both plain and non-plain buckets, along with stale reviver and public type metadata.
- fix: ensure bigint literal doesn't throw with encapsulation
- feat: add
encapsulateErroroption for control of throwing properties; fixes #29 - docs: make mention of fact that there is an asynchronous API today, just not a streaming one
- chore: update devDeps.
- fix: preserve shared references when reviving paths nested in replaced containers (e.g.,
Setvalues) - fix: wait for nested async child revivals before running parent revivers during
reviveAsync - chore: bump
enginesto Node 22+ - chore: update devDeps.
- fix(security): disallow
__proto__property as per https://gist.github.com/tariqhawis/da226bfe6332e987a659dd622f535dd6 - chore: update devDeps.
- fix: TypeScript typings (separate
ObserverDatafromEncapsulateObserver)
- fix:
NodeNextmoduleResolution
- fix: bundling issue
- feat: TypeScript typings
- fix: support distinguishing of +0 and -0
- fix: switch use of Node 14-unsupported
replaceAll
- BREAKING fix: empty string components of key paths are now escaped (as
'') and''is escaped as''''
- fix: CJS export
- fix: Set (UMD)
browserexport afterimport/require
- chore: update devDeps.
- BREAKING feat: move to named exports
- BREAKING feat: Offer ESM (breaks some paths and adds
exports) - feat: Expose
Typeson.setAtKeyPath
- chore: switches to c8 from nyc for ESM compatibility
- npm: Update devDeps.
- Enhancement: Adds
Typeson.Promise.allSettledutility for parity with otherPromisemethods
- npm: Switch to pnpm
- npm: Update devDeps.
- Breaking change: Drop peerDeps (core-js-bundle, regenerator-runtime) and
avoid need for
regenerator-runtime - Docs: Corrected typo (@stephanemagnenat)
- Linting: Lint per lasest ash-nazg; lint hidden file
- Build: Use "json" extension on RC file; indicate
defaultexports for Rollup - Editorconfig: Enforce JSON spacing
- Testing: Remove need for bootstrap file
- npm: Add coverage in main
testscript - npm: Switch to server without reported vulnerabilities (
http-server) - npm: Replace deprecated
rollup-plugin-babelwith@rollup/plugin-babeland makebabelHelpersbundledvalue explicit - npm: Update devDeps (including changing updated ash-nazg peerDeps.)
- Fix: Avoid treating recurring primitive values as cyclic
- Linting (ESLint): As per latest ash-nazg
- npm: Bump devDeps, peerDeps
- npm: Bumped version as package not seeming to be available for download despite being published
- Enhancement: Allow
TypesonPromiseallandraceto work with non-TypesonPromise - Fix: Allow nested plain objects to async revive
- Fix: Have empty keypath at very front, but nested first otherwise
- Fix: Nested
Undefined - Fix: Avoid recursion if
undefinedorNaN/Infinity/-Infiinityvalues return the same - Fix: Ensure
iterateInarray can have async setting - Testing: Coverage, Intermediate async types
- Docs: Document removing a previously registered spec;
update/clarify
hasConstructorOfnullbehavior
- Fix: Restore old behavior of nullish spec potentially replacing
- Enhancement: Allow nullifying previous
testPlainObjectsspecs (by absence oftest) - npm: Bump devDep.
- Fix: When checking for "null" constructor, return
trueif object created byObject.create(null). This fix only impacts direct use ofTypeson.hasConstructorOf. When internally used in Typeson (ortypeson-registry), it never uses anullsecond argument. - Fix: Throw proper error upon missing reviver
- Fix: Ensure nullish spec is silently ignored
- Fix: Ensure sorting more nested paths first
- Enhancement: Add
engines(also used in Unicorn linting rule) - Testing: Coverage improvements; use mocha and chai
- npm: Split up browser testing to two scripts
- npm: Update devDeps, peerDep (core-js-bundle)
- Enhancement: Allow cloning during encapsulation of (non-registered)
classes using
Symbol.toStringTag(#17)
- Fix: Ensure pointing to existent main CJS file (minified)
- Fix: Ensure
thisis defined with old-style function-based type specs - Fix: Ensure
UndefinedandTypesonPromiserevivers are correctly detected (independent of minification or Babelification). - Linting (ESLint): Switch to more rigorous config (ash-nazg); jsdoc, etc.
- Linting (ESLint): add any html to linting
- Maintenance: Add
.editorconfig - Testing: Add coverage
- npm: Update devDeps/peerDeps
- Enhancement: Add ESM dist format (and use in test and
package.json); provide non-minified versions - Testing: Avoid need for build file (use
esmand relative path for browser test) - npm: Indicate
core-js-bundleandregenerator-runtimeaspeerDependencies(and devDeps) in place of deprecated@babel/polyfill - npm: Update
opn-cli->open-cli; update devDeps; remove now unusedrollup-plugin-node-resolve
- Linting (ESLint): Update
polyfillsfor compat plugin - npm: Update devDeps, including Babel potentially impacting build
- Fix: Sorting issue with plain object revivers (lgtm.com-inspired fix)
- Refactoring: Avoid useless check (lgtm.com-inspired change)
- Fix: Ensure
testPlainObjectsare revived before reference resolution and setting (and before other types) so that objects-to-arrays will be properly referenced in all cases and can thus preserve non-index array properties (fixes #9) - Fix: Allow
iterateIn === 'objectto override array and create object from array - Fix (
reviveAsync): Wait until all TypesonPromises resolve (no tests still) - Enhancement: Add state object option to auto-copy array length onto array-like object clone
- Optimization: Avoid passing around (unchanging)
optswithin innerrevivehandling - Refactoring: Object property shorthand; avoid shadowing; make return
explicit; use
sliceoversubstr - Docs: Further JSDoc
- Testing: Report total passed
- Testing (fix): Ensure using
@babel/polyfill - npm/yarn: Update devDep
- npm: Add yarn to
prepublishOnlyto ensure stays up to date with npmpackage-lock.json
- yarn: Update
yarn.lock
- Fix: Give string tag to
TypesonPromiseto prevent it from passingisUserObject - Linting (Markdown): Update per newer API
- npm: Update devDeps
- Linting (ESLint): Remove unused file from ignore; apply script to whole
repo save ignore file; override new "standard" rule with own
"object-curly-spacing"; avoid Node-11-deprecated
url.parse - Linting (ESLint): Actually use compat plugin (identifies need for promises and URL polyfills as a minimum on some older browsers to get full browser coverage)
- Refactoring: Use object shorthand, destructuring
- Build (Rollup): Switch to terser for minification; avoid plugins where not needed
- npm: Update to Babel 7; update other devDeps; switch to base64-arraybuffer-es6
- Fix: Ensure deleted state object properties are restored
- npm: Update devDeps
- Yarn: Update
yarn.lock - npm: Add
package-lock.json
- Enhancement: Except for
typeandreplacedstates, preserve state object keys (including user-supplied ones) within replacers; add tests - Enhancement: Pass a state object as the second argument to revivers; add tests
- npm: Update devDeps
- Fix
.npmignore
- Build: Add Yarn.lock
- npm: Update dev deps
- Build: Add minification for its own sake and also avoiding our Rollup process (Babel?) unminifying our source and creating inconsistency
- Build: Preminimize internally used constructors so basic functionality not fragile across multiple Typeson instances
- npm: Include typeson.js file with npm in case using as module and also include LICENSE (but ignore new test directory)
- npm: Remove build and prepublish scripts (runs on local installs in npm <= 4)
- Build: Switch from Webpack to Rollup
- npm/Testing: add ESLint script to test routines
- npm/Testing: Add browser test file and npm script
- Testing refactoring: Write tests in ES6
- Testing: Add messages for tests missing them
- gitignore: Ignore new auto-generated test file
- npm: Add
browsertopackage.jsonfor bundlers
- npm: Add
moduletopackage.jsonfor downstream Rollup/Webpack
- For
encapsulateObserver, reporttypeDetectedastruewhen a Typeson-detected type is found but no relevant replacer is present to be performed. - For
encapsulateObserver, reportreplacingastruepreceding a Typeson-detected type replacement. (Can be used to get at the original object value before encapsulation) - npm/Testing: Update dev dependencies
- Add back prepublish script to ensure rebuilding upon publish
- Ensure build occurs on install
- Fix
rootTypeNameto work with promises and for replacements
- Breaking change (minor): Throw upon attempts to register objects with JSON type names
- Breaking change (minor): Include JSON type names on
typeproperty of object passed toencapsulateObserver - Enhancement (Basic API):
specialTypeNamesinstance method to return array of unique Typeson type names - Enhancement (Basic API):
rootTypeNameinstance method to return string of Typeson type name at root if present or the JSON type name otherwise - Enhancement (Basic API): Add
Typeson.getJSONTypeclass method to returnnullandarraywhere appropriate ortypeofotherwise - Enhancement (Basic API): Add
Typeson.JSON_TYPESclass property to list the available JSON types
-
Breaking change: Use object-based structure on
types(esp. important as more possible properties/methods are added, reliance on array ordering will become less manageable/intelligible for users). -
Breaking change: Changed default to optimize and avoid replacement checks on arrays unless there is at least one type whose spec has
testPlainObjectsset. Brings consistency given that non-array plain object types must also have the option set to be discoverable. -
Fix: Allow missing recursive array or object member possibilities
-
Fix: Cross-frame/Cross-module plain-object (including
Object.create(null)) and array detection -
Fix: Escape keypaths to avoid conflicts when property names include dots; fixes #5
-
Fix: Nest inside
$even if object has$typesthat is non-truthy or if it has$typesbut no actual types (with tests) -
Fix: Throw if user attempts to define a type with ID "#"
-
Fix: Implementation of pojo registration. The sugar:
typeson.register({MyClass});failed if parsingundefinedornullsince the tester did not check for that. -
Enhancement (Basic API): Avoid needing a replacer (so that it can add state config without modifying the object and e.g., set to iterate "in" properties; also can be used for validation only)
-
Enhancement (Basic API): Allow
fallbackoption toregisterto assign lower priority to a later registration addition -
Enhancement (Basic API): Support object-based API in addition to function/array (with properties,
test,replace,revive);thiscontext is supplied object -
Enhancement (Basic API): Allow per-method-invocation options on
encapsulate/stringify/revive/parse -
Enhancement (Basic API): Support
encapsulateObservercallback option (sending detectedtypewhen present), adding tests for sync and async -
Enhancement (Types): Allow
encapsulateto represent primitives andreviveto revive them as such (e.g., to encode a bareundefinedin the same manner asundefinedproperties) -
Enhancement (Types): Allow revival to return instanceof
Typeson.Undefinedto indicate restoring toundefined -
Enhancement (Types): Add config
testPlainObjects(which can also work with arrays) to allow (non-recursive) tests and replacements for plain objects (or arrays) -
Enhancement (async):
stringifyAsync,parseAsync,encapsulateAsync,reviveAsyncmethods which return promises; have them usereplaceAsyncandreviveAsyncon type specs where relevant -
Enhancement (async): Add
throwOnBadSyncTypeoption (defaults totrue) which the*Sync/Asyncmethods automatically apply -
Enhancement (async): Rather than relying on Promises proper (which could be desired as encapsulation results, at least as targets for throwing (e.g., Structured Cloning Throwing in
typeson-registry)), require use of aTypeson.Promise()(which supports promise methods) to indicate a result is to be obtained asynchronously. -
Enhancement (utility): Expose
isObject,isPlainObject,isUserObject, andisThenableas class methods ofTypeson -
Enhancement (utility): Allow
Typeson.hasConstructorOfto be tested against classes without constructors -
Enhancement (utility): Add
compareConstructorsmethod for detection of instances likeIntl.CollatorwhosetoStringTagis indistinguishable from other classes; document -
Enhancement (utility): Add
Typeson.toStringTagclass method given frequent need by types -
Enhancement (utility): Add
escapeKeyPathComponent,unescapeKeyPathComponent, andgetByKeyPathas class methods ofTypeson -
Enhancement (key iteration): Allow setting of
iterateInstate ('object' or 'array') by type methods to give purely modular control and ensure iteration on prototype only occurs when set by the type (e.g., so not iterating iterating all objects unless detected as such);iterateIndefaults to not being set. -
Enhancement (key iteration): Allow setting of
iterateUnsetNumericboolean state object property to give purely modular control and ensure iteration of unset (sparse) numeric array indexes only occurs when set by the type (e.g., so not iterating iterating all arrays unless detected as such); defaults tofalse -
Testing (fix): Prevent
ArrayBufferdetection clashing with other types -
Testing bugs: Add test for current behavior of replacer (tester/encapsulator) ordering
-
Testing bugs: Keypaths with property names including dots
-
Testing bugs: Test for clashes with objects using own
$and$typesproperties -
Testing bugs: Ensure preventing types with ID "#"
-
Testing features: Add encapsulate observer tests
-
Testing features: Add
toJSONtests -
Testing features: Add
Typeson.Promiseall/racetests -
Testing features: Support promise-based tests
-
Docs (README): Document new features
-
Docs (README): Describe more of the resulting encapsulated structure
-
Docs (README): Document recursive nature of replacements (and promises)
-
Docs (README): Indicate sequence upon subsequent
registercalls -
Docs (README): Indicate precedence of testing/encapsulating when an array is supplied
-
Docs (README): Indicate support for arrays and primitives at root by return of new object
-
Docs (README): summarize properties and specify types consistently in headers
-
Docs (README): Use backticks to set off code references
-
Docs (README): Improve headings hierarchy, more descriptions and documentation of async/sync methods
-
npm: Update dev dependencies
- Enhancement: Allow reviver to set the explicit value
undefined(by returning an instance ofTypeson.Undefined) - Enhancement: Pass in state objects to tests and replacers so that they can vary their results depending on setting (currently only whether we are iterating an "own" key property or not)
- Refactoring: Remove redundant nullish-check
- Clean-up: Remove trailing WS, consistent semi-colon usage
- Docs: Consistent and best practices heading hierarchy in README
- Docs: Mention use of tester for throwing exceptions
- Docs: Add docs for
stateObj - Docs: Add docs for
undefinedbehavior in encapsulators and revivers, the use ofTypeson.Undefinedto explicitly addundefined