1.0.10 • Published 1 year ago

@cashelng/pro-tils v1.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

pro-tils: a small extensions package which also supported typescript

This package extends global Javascript interfaces with additional utility methods.

Notes:

This will not replace the existing methods, just to create new utility functions attached into prototypes

Please raise an issue, or submit a pull request yourself if you see any overlap.

Why

All of this is just to create utility functions which are usually used in projects, also provide a usage of chaining functions efficiently. Chaining functions can indeed reduce the need for intermediate variable declarations, leading to more concise and readable code.

Let consider below example, we had an object which is like

type User = {
  id: number;
  name: string;
  phone: number;
  address?: {
    street?: string;
    ward?: string;
    city?: string;
  };
};

As the Front-end logic, you want to translate the city with its value. It's normally to write

const user: User = { ...userValue };
const city = user.address?.city;
const cityTranslation = city && translator(city);
{ ...rest }

<p>{cityTranslation}</p>

Right now it is just simply:

<p>{user.getDeep('address.city').exist((cityValue) => translator(city))}</p>

Documents

Check out this documentation for installation and usage

Contributing

Contributions are welcome! Please feel free to fork the repository, make improvements, and submit pull requests.

License

This project is licensed under the MIT License

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago