Skip to content

Latest commit

 

History

History
24 lines (22 loc) · 2.1 KB

File metadata and controls

24 lines (22 loc) · 2.1 KB

So you want to contribute to Micro-dash? That's great! This guide shows everything that goes into adding a function to the library, along with some helpful hints to accomplish them.

Adding a function

  1. Write the function.
    1. Find the documentation for it on Lodash.
    2. Create the file in projects/micro-dash/src/lib/<category>/<function-name>.ts, where the categorization matches that in Lodash (e.g. "array" or "collection").
    3. Copy the description from lodash into the jsdoc for the function. No need to copy the descriptions of the arguments or return value, only the stuff above that. Don't try to improve the description, except by removing irrelevant parts that will not be supported in Micro-dash.
    4. Implement it!
    5. Add it to the index.ts file within its directory.
  2. Write the spec. This is the hard part.
    1. Create the spec file next to the main file (in projects/micro-dash/src/lib/<category>/<funtion-name>.spec.ts).
    2. Search for everywhere the function is tested in Lodash's test suite, and create equivalent tests in Micro-dash for the ones that apply.
      • The tests are written a very different style - compare with existing Micro-dash tests to get a feel for it.
      • If there are similar functions already in Micro-dash, use their spec as a guide. Sometimes many tests can copied from that function with only small tweaks.
    3. Run the tests with yarn test micro-dash.
  3. Calculate the sizes.
    1. Create 2 files:
      1. projects/calc-sizes/src/app/<category>/<function-name>.lodash.ts
      2. projects/calc-sizes/src/app/<category>/<function-name>.microdash.ts
    2. Add simple uses of the function to both files. The files should be identical except for the import lines (where one imports from lodash-es, and the other from micro-dash).
      • If the function returns a value, console.log the output to be sure tree shaking doesn't decide the whole thing is unnecessary.
    3. Run yarn calc-sizes and enter the function name in kebab-case.
  4. File the PR!