1.3.8 • Published 9 months ago
@ialopezg/commonjs v1.3.8
CommonJS
A collection of utility functions for handling strings, numbers, dates, objects, booleans, paths, and more.
Installation
npm install @ialopezg/commonjsUsage
import '@ialopezg/commonjs';
// strings
const cardNumber = '1234-5678-9098-7654';
const part1 = (cardNumber.slice(0, 4) + '-').padWithChar('*', 9, 'right');
const part2 = ('-' + cardNumber.slice(-4)).padWithChar('*', 9, 'left');
console.log([part1, part2].join('-')); // Will produce 1234-****-****-7654
// numbers
console.log('41'.padWithChar('*', 4, 'right')); // will produce 42**
console.log((42).padWithChar('0', 4, 'left')); // will produce 0042
// dates
console.log(new Date(2010, 1, 14, 15, 25, 50, 125).humanize('w, l D1 Y, h:m2:s2 a')); // will procuce Monday, February 1st 2025, 3:30:00 pmDocumentation
The library is organized into several helper modules. Click on the links below for detailed usage and examples:
| Helper | Description | Extension |
|---|---|---|
| Date | Extends native Date and DateConstructor type with extra functionalities such as: humanize, humanizeTimeDiff, relativeTime, timeDiff | ✓ |
| Number | Extends native Number and NumberConstructor type with extra functionalities such as: getOrdinal, padWithChar | ✓ |
| String | Extends native string type with extra functionalities such as: padWitchChar | ✓ |
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.
License
This project is under MIT License.
1.3.7
9 months ago
1.3.6
9 months ago
1.2.7
10 months ago
1.3.5
10 months ago
1.2.6
10 months ago
1.3.4
10 months ago
1.2.5
10 months ago
1.3.3
10 months ago
1.2.4
10 months ago
1.3.2
10 months ago
1.3.1
10 months ago
1.3.0
10 months ago
1.3.8
9 months ago
1.2.0
2 years ago
1.1.6
2 years ago
1.1.5
2 years ago
1.2.3
2 years ago
1.1.4
2 years ago
1.2.2
2 years ago
1.1.3
2 years ago
1.2.1
2 years ago
1.1.1
3 years ago
1.1.2
3 years ago
1.1.0
3 years ago
1.0.9
3 years ago
1.0.10
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago