Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stefanwimmer128/jwin
JustWhatINeed is a JavaScript library, which adds some usefull functions that are often used by me
https://github.com/stefanwimmer128/jwin
Last synced: 2 days ago
JSON representation
JustWhatINeed is a JavaScript library, which adds some usefull functions that are often used by me
- Host: GitHub
- URL: https://github.com/stefanwimmer128/jwin
- Owner: stefanwimmer128
- License: isc
- Created: 2016-06-17T18:55:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-06-18T19:15:50.000Z (over 8 years ago)
- Last Synced: 2024-12-10T22:13:46.187Z (28 days ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/jwin
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jwin
JustWhatINeed is a JavaScript library, which adds some useful functions that are often used by me
## How to install?
Installing this module is easy, just type:
``` bash
npm i [-S|--save] jwin[@[version]]
```for example:
``` bash
npm i -S [email protected]
```## How to include?
``` javascript
const $ = require("jwin");
```## Examples of what you can do
``` javascript
const $ = require("jwin");const myGroup = new $.Group([1, 2]); // Creates Group with elements [1, 2]
myGroup.add(3); // Ads 3 to elements [1, 2, 3]
myGroup.add(4); // Ads 4 to elements [1, 2, 3, 4]const add = [5, 6];
const itr = new $.Iterator(add); // Creates an Iterator based on elements [5, 6]
while (itr.hasNext()) // Cycle as long there are values in the Iterator
{
myGroup.add(itr.next()); // Adds current element to myGroup and cycle through the elements
}const mapedGroup = myGroup.map((num) => num * 2); // See Array.prototype.map: [2, 4, 6, 8, 10, 12]
const filteredGroup = mapedGroup.filter((num) => num > 6); // See Array.prototype.filter: [8, 10, 12]
const sum = filteredGroup.reduce((sum, num) => sum + num, 0); // See Array.protorype.reduce: 30
console.log(sum); // 30
```