Skip to content

A Pythonic `range(...)` utility that works with both `for/of` and `in` operations

Notifications You must be signed in to change notification settings

WebReflection/range

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@webreflection/range

build status Coverage Status

A Pythonic range(start[, stop[, steps = 1]]) function that works in both for / of and with value in range(...) operations.

import range from '@webreflection/range';

for (const i of range(0, 3))
  console.log(i); // 0, 1, 2

if (1 in range(0, 2))
  console.log('1 is in range [0, 1, 2]');

API

  • range(3) is equivalent of range(0, 3) and yields [0, 1, 2]
  • range(3, 5) will yield [3, 4]
  • range(0, 5, 2) will yield [0, 2, 4];
  • 1 in range(0, 2) will be true but 2 in range(0, 2) will be false
  • [...range(0, 3)] is valid as for (const i of range(0, 3));

That's it.

About

A Pythonic `range(...)` utility that works with both `for/of` and `in` operations

Resources

Stars

Watchers

Forks

Packages

No packages published