metaschema icon indicating copy to clipboard operation
metaschema copied to clipboard

Optimize kinds.js module. Add tests

Open rustworthy opened this issue 1 year ago • 0 comments

  • [x] tests and linter show no problems (npm t)
  • [x] tests are added/updated for bug fixes and new features
  • [x] code is properly formatted (npm run fmt)
  • [ ] description of changes is added in CHANGELOG.md // N/A
  • [ ] update .d.ts typings // N/A

Changes:

  • return early if schema name OR (!) fields not specified when building projection;
  • check that 'root' passed to "projection" func respects Schema API;
  • add tests for "projection" func;
  • treat projection as a private case of 'kindMemory' and simplify 'getKindMetadata' dispatcher func;
  • use 'KIND_STORED_DEFAULT_META' and 'KIND_MEMORY_DEFAULT_META' constants to store module defaults;

As a side-note: both 'schema' and 'fields' are words kind of reserved for Schema instance and field attribute of schema instance accordingly, so I would suggest using schemaName and fieldNames where appropriate; not always this is clear from the context.

rustworthy avatar Sep 16 '23 20:09 rustworthy