typeswiss v0.2.5
TypeSwiss
A modern swiss army knife library for utility functions, all written in TypeScript and type-safe.
Similar to lodash but with a focus on type-safety, tree-shaking, and leveraging the platform whenever possible.
Features
- π¦ Modern and tree-shakeable
- π₯ Written in and designed to work with TypeScript (plain JavaScript also supported)
- π« No runtime dependencies
- π Provides type-safe utility functions
- π± Growing collection of 40+ utility functions
Installation
You can install TypeSwiss using npm or yarn:
npm install typeswiss
# or
yarn add typeswissUsage
TypeSwiss provides a set of utility functions that can be imported and used in your TypeScript projects. Hereβs an example of how to import and use the pick function:
import { objectKeys } from 'typeswiss';
import { pick } from 'typeswiss/pick'; // either syntax works
interface ExampleObj {
a: number;
b: number;
c: number;
}
const obj: ExampleObj = {
a: 1,
b: 2,
c: 3,
};
const result = objectKeys(obj); // ["a", "b", "c"]
// ^? ("a" | "b" | "c")[]
const result2 = pick(obj, ['a', 'b']); // { a: 1, b: 2 }
// ^? Pick<ExampleObj, "a" | "b">Contributing
If you find a bug or have a feature request, please open an issue on the GitHub repository. Pull requests are also welcome!
Developing
Watch and rebuild code with tsup:
yarn devRun tests with vitest:
yarn test
# or watch for changes
yarn test:watchLicense
TypeSwiss is MIT licensed.
Building
Build package with tsup for production.
yarn buildLinking
Often times you want to link the package you're developing to another project locally to test it out to circumvent the need to publish it to NPM.
For this we use yalc which is a tool for local package development and simulating the publishing and installation of packages.
In a project where you want to consume your package simply run:
npx yalc link my-react-package
# or
yarn yalc add my-react-packageLearn more about yalc here.
Committing
When you are ready to commit simply run the following command to get a well formatted commit message. All staged files will automatically be linted and fixed as well.
yarn commitReleasing, tagging & publishing to NPM
Create a semantic version tag and publish to Github Releases. When a new release is detected a Github Action will automatically build the package and publish it to NPM.
yarn release