https://github.com/venryx/js-vextensions
Extensions for Javascript, by Venryx.
https://github.com/venryx/js-vextensions
Last synced: 11 months ago
JSON representation
Extensions for Javascript, by Venryx.
- Host: GitHub
- URL: https://github.com/venryx/js-vextensions
- Owner: Venryx
- License: mit
- Created: 2017-12-31T23:28:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-11-27T09:47:48.000Z (over 1 year ago)
- Last Synced: 2025-08-16T09:43:31.793Z (11 months ago)
- Language: TypeScript
- Size: 1.47 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JS - VExtensions
Extensions for Javascript, by Venryx.
### Installation
```
npm install js-vextensions --save-exact
```
The `--save-exact` flag is recommended, since this package uses [Explicit Versioning](https://medium.com/sapioit/why-having-3-numbers-in-the-version-name-is-bad-92fc1f6bc73c) (`Release.Breaking.FeatureOrFix`) rather than SemVer (`Breaking.Feature.Fix`).
To let npm increment `FeatureOrFix` (recommended), prepend "`~`" to its version in `package.json`. (for `Breaking`, prepend "`^`")
### Using class methods/extensions
##### Approach 1: (as class methods/extensions)
Setup:
```
// To add the class-extension typings (so typescript knows the class/prototype contains those methods)
// /// // type import approach A
// import "js-vextensions/Helpers/@ApplyCETypes"; // type import approach B
type __ = typeof import("../node_modules/js-vextensions/Helpers/@ApplyCETypes"); // type import approach C (recommended)
// To actually add the methods to the class-prototype chain (so it works at runtime)
import "js-vextensions/Helpers/@ApplyCECode.js";
```
Usage:
```
const array = [1, 2, 3];
console.log(array.Skip(1)); // logs "2,3"
```
##### Approach 2.A: (using wrapper, with type specified)
```
const array = [1, 2, 3];
console.log(ArrayCE(array).Skip(1)); // logs "2,3"
```
##### Approach 2.B: (using wrapper, with type inferred)
```
const array = [1, 2, 3];
console.log(CE(array).Skip(1)); // logs "2,3"
```
##### Approach 3: (using standalone functions)
```
const array = [1, 2, 3];
console.log(ArrayCES.Skip(array, 1)); // logs "2,3"
```