sindresorhus / Magic Iterable
Licence: mit
Call a method on all items in an iterable by calling it on the iterable itself
Stars: ✭ 159
Programming Languages
javascript
184084 projects - #8 most used programming language
Labels
Projects that are alternatives of or similar to Magic Iterable
Defer.js
🥇 A super small, super efficient library that helps you lazy load everything like images, video, audio, iframe as well as stylesheets, and JavaScript.
Stars: ✭ 138 (-13.21%)
Mutual labels: npm-package
Aws Lambda Libreoffice
85 MB LibreOffice to fit inside AWS Lambda compressed with Brotli
Stars: ✭ 145 (-8.81%)
Mutual labels: npm-package
Gloria
Gloria is a static website generator, based on NodeJS.
Stars: ✭ 153 (-3.77%)
Mutual labels: npm-package
Kafkajs
A modern Apache Kafka client for node.js
Stars: ✭ 2,315 (+1355.97%)
Mutual labels: npm-package
Handlebars Webpack Plugin
Renders your html-template at build time
Stars: ✭ 135 (-15.09%)
Mutual labels: npm-package
Gh Got
Convenience wrapper for Got to interact with the GitHub API
Stars: ✭ 156 (-1.89%)
Mutual labels: npm-package
React Bnb Gallery
Simple react-based photo gallery inspired by Airbnb image gallery.
Stars: ✭ 145 (-8.81%)
Mutual labels: npm-package
Transliterate
Convert Unicode characters to Latin characters using transliteration
Stars: ✭ 152 (-4.4%)
Mutual labels: npm-package
Csv Writer
Convert objects/arrays into a CSV string or write them into a CSV file
Stars: ✭ 140 (-11.95%)
Mutual labels: npm-package
Create React Component Folder
Creates react component folder structure
Stars: ✭ 139 (-12.58%)
Mutual labels: npm-package
Do Not Disturb
Control the macOS `Do Not Disturb` feature
Stars: ✭ 155 (-2.52%)
Mutual labels: npm-package
To Milliseconds
Convert an object of time properties to milliseconds: `{seconds: 2}` → `2000`
Stars: ✭ 136 (-14.47%)
Mutual labels: npm-package
React Render In Browser
React library to render browser specific content
Stars: ✭ 157 (-1.26%)
Mutual labels: npm-package
Watermark
Add watermark on images use HTML5 and Javascript.
Stars: ✭ 154 (-3.14%)
Mutual labels: npm-package
Inspirational Quotes
💡 A simple NPM Package which returns random Inspirational Quotes. Get your daily quote and stay motivated! ✌️ 🌸
Stars: ✭ 150 (-5.66%)
Mutual labels: npm-package
magic-iterable
Call a method on all items in an iterable by calling it on the iterable itself
Uses the Proxy
API.
Install
$ npm install magic-iterable
Usage
const magicIterable = require('magic-iterable');
const x = {
i: 0,
increment(value) {
this.i += value;
return this.i;
}
};
const array = [x, x, x, x];
const magicArray = magicIterable(array);
Array.isArray(magicArray);
//=> true
magicArray.increment(2);
//=> [2, 4, 6, 8];
x.i;
//=> 8
const magicIterable = require('magic-iterable');
// Subscribes to click events for all `<a>` elements
magicIterable(document.querySelectorAll('a')).addEventListener('click', () => {
console.log('Click');
});
API
magicIterable(iterable)
Returns a version of iterable
that when you call a method on it, it will call that method on all items in the iterable and return an array with the result.
iterable
Type: Iterable
(For example, an Array
)
Iterable where all the items has the method you want to call.
Related
-
on-change - Watch an object or array for changes (Uses
Proxy
too) -
negative-array - Negative array index support (Uses
Proxy
too) -
known - Allow only access to known object properties (Uses
Proxy
too)
License
MIT © Sindre Sorhus
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].