@bramus/range

中文文档
1.1.2发布于 2021/12/18MITES Module零依赖近 30 天下载 1.1万

Create an array containing a range of elements (cfr. PHP's range)

原始使用文档
文档目录5 节
  1. Installation
  2. Usage / Example
  3. API
  4. Limitations
  5. License

Range

Create an array containing a range of elements (cfr. PHP's range)

Installation

npm i @bramus/range

Usage / Example

import { range } from '@bramus/range';

const r1 = range(0, 12);
// ~> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

const r2 = range(7, 12);
// ~> [7, 8, 9, 10, 11, 12]

const r3 = range(0, 100, 10);
// ~> [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]

🔗 Try it out online in the playground: https://codepen.io/bramus/pen/dyVMPxV

API

The exposed function has an API identical to PHP's range method:

range(start, end, step = 1);

Parameters:

  • start: First value of the sequence.
  • end: The sequence is ended upon reaching the end value.
  • step (default: 1): If a step value is given, it will be used as the increment between elements in the sequence. step should be given as a positive number. If not specified, step will default to 1.

Limitations

Unlike PHP's range, this function is limited to numbers only. In case you do want to get letters, combine range() with Array.map().

License

@bramus/range is released under the MIT public license. See the enclosed LICENSE for details.

版本与发布记录

@bramus/range 共发布 6 个版本,首次发布于 2021/12/06;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.2latest2021/12/184 年前
1.1.2-beta.0beta2021/12/184 年前
1.1.12021/12/184 年前
1.1.02021/12/184 年前
1.0.12021/12/064 年前
1.0.02021/12/064 年前

关于 @bramus/range 的常见问题

@bramus/range 是什么?

Create an array containing a range of elements (cfr. PHP's range)

如何安装 @bramus/range?

在项目目录运行 npm install @bramus/range,或使用 pnpm add / yarn add / bun add。

@bramus/range 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bramus__range 是否存在。

@bramus/range 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bramus/range 可以商用吗?

@bramus/range 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bramus/range 的下载量有多少?

根据 npm 官方下载统计,@bramus/range 在 2026/10/09 – 2026/11/07 这 30 天内被下载 10,626 次,日均约 354 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bramus/range 还在维护吗?

最新版本 1.1.2 发布于 2021/12/18(4 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/12/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。