Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Python like utility functions for JS: `range`, `enumerate`, `zip` and `items`.
Python like utility functions for JavaScript: range
, enumerate
, items
, zip
and zipLongest
.
These functions return an Iterator
instance similar to Python Iterators.
This Iterator
implementation is lazy evaluated,
offers map
,
filter
,
reduce
,
some
,
every
and Symbol.asyncIterator
interfaces.
npm install pythonic --save
import {range} from 'pythonic';
range(3).map(x => console.log(x + 1));
// 1
// 2
// 3
for (const i of range(10, 25, 5))
console.log(i);
// 10
// 15
// 20
console.log(range(5).reduce((accumulator, current) => accumulator + current));
// 10
import {enumerate} from 'pythonic';
const arr = ['a', 'b'];
for (const [index, value] of enumerate(arr))
console.log(`index: ${index}, value: ${value}`);
// index: 0, value: a
// index: 1, value: b
import {zip, zipLongest} from 'pythonic';
const arr1 = ['a', 'b'];
const arr2 = ['c', 'd', 'e'];
for (const [first, second] of zip(arr1, arr2))
console.log(`first: ${first}, second: ${second}`);
// first: a, second: c
// first: b, second: d
for (const [first, second] of zipLongest(arr1, arr2))
console.log(`first: ${first}, second: ${second}`);
// first: a, second: c
// first: b, second: d
// first: undefined, second: e
// unzip
const [arrayFirst, arraySecond] = [...zip(...zip(arr1, arr2))];
import {items} from 'pythonic';
const obj = {a: 'aa', b: 'bb'};
for (const [key, value] of items(obj))
console.log(`key: ${key}, value: ${value}`);
// key: a, value: aa
// key: b, value: bb
const map = new Map([[1, 'one'], [2, 'two']]);
for (const [key, value] of items(map))
console.log(`key: ${key}, value: ${value}`);
// key: 1, value: one
// key: 2, value: two
import {Iterator, range} from 'pythonic';
const randomIntegers = (size, start, stop) => new Iterator(function * () {
for (const _ of range(size))
yield Math.floor(Math.random() * (stop - start) + start);
});
const randomNumbers = randomIntegers(3, 10, 1000);
for (const randomNumber of randomNumbers)
console.log(randomNumber);
// 685
// 214
// 202
console.log(randomNumbers.some(value => value > 10));
// true
console.log(randomNumbers.every(value => value < 1000));
// true
FAQs
Python like utility functions for JS: `range`, `enumerate`, `zip` and `items`.
The npm package pythonic receives a total of 263 weekly downloads. As such, pythonic popularity was classified as not popular.
We found that pythonic demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.