![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
py-range-ts
Advanced tools
Inspired by range function for Python. PyRange creates an object that stores only 3 values (start, stop, step) and corresponding methods (map, forEach, fill, toArray, toIterator, ...).
range
function for Python.PyRange
const r = new PyRange(5, 10, 2);
console.log(r);
// PyRange { _start: 5, _stop: 10, _step: 2 }
console.log(r.toArray());
// [ 5, 7, 9 ]
pyRange()
pyRange(stop:number)
console.log(pyRange(10));
// PyRange { _start: 0, _stop: 10, _step: 1 }
console.log(pyRange(-50));
// PyRange { _start: 0, _stop: -50, _step: -1 }
pyRange(start:number, stop:number)
console.log(pyRange(0, 20));
// PyRange { _start: 0, _stop: 20, _step: 1 }
console.log(pyRange(3, -5));
// PyRange { _start: 3, _stop: -5, _step: -1 }
pyRange(start:number, stop:number, step:number)
console.log(pyRange(0, 12, 3));
// PyRange { _start: 0, _stop: 12, _step: 3 }
console.log(pyRange(0, -12, -3));
//PyRange { _start: 0, _stop: -12, _step: -3 }
map()
It works similar to Array.prototype.map()
;
const elements: string[] = pyRange(0, -12, -3).map((value, index) => {
return `index= ${index}, value= ${value}`;
});
console.log('[map]', elements);
// [map] [
// 'index= 0, value= 0',
// 'index= 1, value= -3',
// 'index= 2, value= -6',
// 'index= 3, value= -9'
// ]
mapAsync()
const elements = await pyRange(0, 12, 4).mapAsync(async (value, index) => {
return { index, value };
});
console.log('[elements]', elements);
// [elements] [
// { index: 0, value: 0 },
// { index: 1, value: 4 },
// { index: 2, value: 8 }
// ]
forEach()
It works similar to Array.prototype.forEach()
.
pyRange(3).forEach((value, index) => {
console.log('[forEach]', `value= ${value} ; index= ${index}`);
});
// [forEach] value= 0 ; index= 0
// [forEach] value= 1 ; index= 1
// [forEach] value= 2 ; index= 2
forEachAsync()
await pyRange(3, 6).forEachAsync(async (value, index) => {
console.log('[forEachAsync]', `value= ${value} ; index= ${index}`);
});
// [forEachAsync] value= 3 ; index= 0
// [forEachAsync] value= 4 ; index= 1
// [forEachAsync] value= 5 ; index= 2
toIterator()
for (const value of pyRange(5, 8).toIterator()) {
console.log('[for-of]', `value= ${value}`);
}
// [for-of] value= 5
// [for-of] value= 6
// [for-of] value= 7
console.log('[toArray]', pyRange(0, 12, 3).toArray());
// [toArray] [ 0, 3, 6, 9 ]
console.log('[fill]', pyRange(5).fill(0));
// [fill] [ 0, 0, 0, 0, 0 ]
toArray()
console.log('[toArray]', pyRange(0, 12, 3).toArray());
// [toArray] [ 0, 3, 6, 9 ]
fill()
console.log('[fill]', pyRange(5).fill(0));
// [fill] [ 0, 0, 0, 0, 0 ]
console.log(
'[fill]',
pyRange(5).fill({
type: 'Object',
value: 'Some values',
}),
);
// [fill] [
// { type: 'Object', value: 'Some values' },
// { type: 'Object', value: 'Some values' },
// { type: 'Object', value: 'Some values' },
// { type: 'Object', value: 'Some values' },
// { type: 'Object', value: 'Some values' }
// ]
toObject()
console.log(pyRange(5, 10).toObject());
// { start: 5, stop: 10, step: 1 }
FAQs
Inspired by range function for Python. PyRange creates an object that stores only 3 values (start, stop, step) and corresponding methods (map, forEach, fill, toArray, toIterator, ...).
We found that py-range-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.