0.2.5 β€’ Published 12 months ago

typeswiss v0.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

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 typeswiss

Usage

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 dev

Run tests with vitest:

yarn test
# or watch for changes
yarn test:watch

License

TypeSwiss is MIT licensed.

Building

Build package with tsup for production.

yarn build

Linking

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-package

Learn 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 commit

Releasing, 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
0.2.5

12 months ago

0.2.4

12 months ago

0.2.3

12 months ago

0.2.2

12 months ago

0.2.1

12 months ago

0.2.0

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.1-0

1 year ago