avatar imageOska Ng

JS Library - Digdata

By Oska Ng on Nov 1, 2022
digdata

Technologies

This library primarily targets times before the introduction of Optional Chaining. If your codebase supports Optional Chaining, it’s advisable to use it. However, there may be instances where this library is preferred, such as when dealing with large access to a single object and aiming to enhance performance using “cursor” methods. Nonetheless, native support typically offers better performance compared to this library.

Key Highlights

  1. Almost 100% full coverage test!
  2. Added ESM support.
  3. Lightweight zero dependency library.
  4. Work with Github CI, Github Packages.
PASS  ./index.test.js
  √ Should dot string notation accepted. (3ms)
  √ Should object dot string notation accepted.
  √ Should array dot string notation accepted. (1ms)
  √ Should equal symbol return object if target is array object based on condition.
  √ Should equal symbol return array if target is array based on condition.
  √ Should equal symbol return null when target not exists. (1ms)
  √ Should arrayMap symbol return specific key
  √ Should comma symbol work with arrayMap symbol return multiple keys
  √ Should pipe symbol return first truth value (1ms)
  √ Should return null if target exists.
  √ Should return null if object is falsy value.
  √ Should run invoke if function and data found. (1ms)
  √ Should skip if function not found.
  √ Should `cursor` build options object
  √ Should build cache when cursor not null
  √ Should get from cache when cursor not null and key exist (1ms)
  √ Should `withOptions` set disableTracker on options
  √ Should `setOptions` update options object.

----------|---------|----------|---------|---------|-------------------
| File       | % Stmts   | % Branch   | % Funcs   | % Lines   | Uncovered Line #s   |
| ---------- | --------- | ---------- | --------- | --------- | ------------------- |
| All files  | 100       | 95.83      | 100       | 100       |
| index.js   | 100       | 95.83      | 100       | 100       | 155,159             |
| ---------- | --------- | ---------- | --------- | --------- | ------------------- |
Test Suites: 1 passed, 1 total
Tests:       18 passed, 18 total
Snapshots:   0 total
Time:        1.562s
Ran all test suites.
  1. Caching cursor - to provide maximum performance when dealing really big of JSON objects.
  2. Invoke Symbol - to support data transformation.
  3. Pipe Symbol - to support multiple data with first come first take priority.
  4. ArrayMap Symbol - to extract data with filter functionality.
  5. Equal Symbol - to get the data based on the input filter, array will use contains check automatically.
  6. Comma Symbol - to extract multiple property from the JSON.

References

  1. Github
  2. Documentation
© Copyright 2024 by Oska Ng. Built with ❤️