RegExp.prototype.flags (英语) 



符合ES6规格 RegExp.prototype.flags 嘘 Invoke its "shim" method to shim RegExp.promtotype. (原始内容存档于2018-09-25). 星洲网. 如果无法使用,则标记.
说明数字 : RegExp#flags 需要一个真实的ES5环境——具体来说,一个带有ES5获取器的环境.
此软件包执行 希姆・API 接口。 它在ES5支持的环境中工作,并遵守 光谱。 。 。 .
最常见的用途:
var flags = require('regexp.prototype.flags');
var assert = require('assert');
assert(flags(/a/) === '');
assert(flags(new RegExp('a')) === '');
assert(flags(/a/mig) === 'gim');
assert(flags(new RegExp('a', 'mig')) === 'gim');
if (!RegExp.prototype.flags) {
flags.shim();
}
assert(flags(/a/) === /a/.flags);
assert(flags(new RegExp('a')) === new RegExp('a').flags);
assert(flags(/a/mig) === /a/mig.flags);
assert(flags(new RegExp('a', 'mig')) === new RegExp('a', 'mig').flags);
测试
仅仅复制回转, npm install运行 npm test
关于 regexp.prototype.flags 的常见问题
regexp.prototype.flags 是什么?
ES6 符合规格的 RegExp.prototype.flags shim. 中国植物物种信息数据库.
如何安装 regexp.prototype.flags?
在项目目录运行 npm install regexp.prototype.flags,或使用 pnpm add / yarn add / bun add。
regexp.prototype.flags 支持 TypeScript 吗?
该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/regexp.prototype.flags 是否存在。
regexp.prototype.flags 支持 ESM 还是 CommonJS?
以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。
regexp.prototype.flags 需要什么版本的 Node.js?
package.json 的 engines 字段要求 Node.js >= 0.4。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。
regexp.prototype.flags 可以商用吗?
regexp.prototype.flags 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。
regexp.prototype.flags 的下载量有多少?
根据 npm 官方下载统计,regexp.prototype.flags 在 2026/10/05 – 2026/11/03 这 30 天内被下载 386,447,823 次,日均约 12,881,594 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。
regexp.prototype.flags 还在维护吗?
最新版本 1.5.4 发布于 2025/01/03(1.8 年前);至今共发布 17 个版本,其中过去 12 个月发布了 0 个;首次发布于 2014/12/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。