https://github.com/afeiship/protofill
Enhance native JavaScript prototypes with custom methods safely.
https://github.com/afeiship/protofill
enhance javascript js prototype safely
Last synced: 29 days ago
JSON representation
Enhance native JavaScript prototypes with custom methods safely.
- Host: GitHub
- URL: https://github.com/afeiship/protofill
- Owner: afeiship
- License: mit
- Created: 2018-01-03T01:33:08.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-09-07T02:32:58.000Z (almost 3 years ago)
- Last Synced: 2025-09-24T01:25:38.775Z (9 months ago)
- Topics: enhance, javascript, js, prototype, safely
- Language: TypeScript
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# protofill
> Enhance native JavaScript prototypes with custom methods safely.
[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]
## installation
```shell
npm install @jswork/protofill
# add types for `src/global.d.ts`
import '@jswork/protofill/dist/types';
```
## usage
```js
// just oneline
import '@jswork/protofill'
// ------ Array ----
const arr = [1,2,3]
// set/get first:
arr.first = 'a';
arr.first;
// set/get last:
arr.last = 'a';
arr.last;
// filter2tuple
const numbers = [1, 2, 3, 4, 5];
const result = numbers.filter2tuple((item) => item > 2);
// result: [[3, 4, 5], [1, 2, 3, 4, 5]]
// ------ Date ----
const date = new Date();
format: date.format('YYYY-MM-DD HH:mm:ss');
```
## license
Code released under [the MIT license](https://github.com/afeiship/protofill/blob/master/LICENSE.txt).
[version-image]: https://img.shields.io/npm/v/@jswork/protofill
[version-url]: https://npmjs.org/package/@jswork/protofill
[license-image]: https://img.shields.io/npm/l/@jswork/protofill
[license-url]: https://github.com/afeiship/protofill/blob/master/LICENSE.txt
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/protofill
[size-url]: https://github.com/afeiship/protofill/blob/master/dist/protofill.min.js
[download-image]: https://img.shields.io/npm/dm/@jswork/protofill
[download-url]: https://www.npmjs.com/package/@jswork/protofill