A dependency-free, Typescipt-first, pure-function String
manipulation library
# yarn
yarn add @juliancoleman/orchestra
# npm
npm i @juliancoleman/orchestra
Feel free to fork and clone this repo to start out. Once cloned, go ahead and run one of the following commands:
# yarn
yarn
# npm
npm i
If you run into the following error while running the test suite on MacOS:
$ jest --config ./jest.config.js -i --watch
Error: `fsevents` unavailable (this watcher can only be used on Darwin)
then run the following:
brew install watchman
You can run all tests in Orchestra
by simply running:
# yarn
yarn test
# npm
npm run test
This command will spin up Jest, run all tests, and watch
for additional changes to files. The watcher will restart
if it detects a change in any .js
or .ts
file.
On the first run of Jest, it may report
0 suites found
. Just hita
and let it find the suite.
To view a map of the coverage report, run the following:
# yarn
yarn coverage
# npm
npm run coverage
This spins up jest, runs all tests, runs a coverage report, and prints the report to the console. This command does not watch for file changes.
# yarn
yarn coverage:serve
# npm
npm run coverage:serve
This spins up Jest, runs all tests, runs a coverage report, and spins up a web server, generating a URL when the server is ready. This command does not watch for file changes.
Jest has a very familiar feel to the likes of mocha and chai. To be as basic as possible, your test file will look something like this...
describe("#myFunction", () => {
it("passes the test", () => {
expect(true).toBe(true);
});
});
So, you have a great idea on a new function you would like Orchestra to adopt. I appreciate the contribution!
lib/
and create a new folderThe folder structure should look like the following
myFunction/ - myFunction.ts - myFunction.spec.ts
(don't create any
index.ts
files)
- Begin creating your function.
- Don't forget to utilize TypeScript and its type system.
- Any contribution with missing types will be automatically rejected.
- Test your function.
- use the example above to get started.
- write as many tests you feel are necessary (the more, the better!).
- Leaving the demo
describe
block in your test file will also earn you a rejection.- Upon completion of the function and its tests, run the following command:
# yarn
yarn generate-barrels
# npm
npm run generate-barrels
This will automatically add an index.ts
file to your new
folder, as well as add your new function to the list of
Orchestra's module exports. You won't need to worry about
populating the index
as barrelsby
has already taken care of that for you. If you're
unfamiliar with the barrel pattern,
I can't recommend reading up on it enough.
You can then do something like this in a project that uses Orchestra as a dependency:
import { myFunction } from "orchestra";