@axway/amplify-utils

中文文档
3.0.0发布于 2026/11/17Apache-2.0ES Module近 30 天下载 7629

Axway 放大工具库

中文使用文档
文档目录5 节
  1. 安装
  2. 小时
  3. 路径
  4. 倾斜
  5. 法律

放大 Utils 图像

一个用于解析常见文件系统,路径等的库.

安装

npm i @axway/amplify-utils --save

小时

import {
    existsSync,
    isDir,
    isFile,
    locate
} from '@axway/amplify-utils';

console.log(existsSync('/path/to/something'));

console.log(isDir('/path/to/some/dir'));

console.log(isFile('/path/to/some/file'));

// recursively search a directory for a file up to a specified depth
console.log(locate('/path/to/some/dir', 'somefile', 2));

路径

import {
    expandPath,
    real
} from '@axway/amplify-utils';

// replace ~ with the user's home path and join any additional segments
console.log(expandPath('~/foo', 'bar'));

// resolves symlinks to real path, even if symlink is broken
console.log(real('/some/path'));

倾斜

import { arch } from '@axway/amplify-utils';

console.log(arch()); // 'x86' or 'x64'
import { arrayify } from '@axway/amplify-utils';

console.log(arrayify('foo')); // [ 'foo' ]

console.log(arrayify([ 'a', '', null, 'b' ], true)); // [ 'a', 'b' ]
import { assertNodeEngineVersion } from '@axway/amplify-utils';

// throw an exception if current node version doesn't satisfy the `engines.node` version
assertNodeEngineVersion(require('package.json'));
import { cache } from '@axway/amplify-utils';

const now = () => Date.now();

const first = await cache('my namespace', now);
const second = await cache('my namespace', now);
assert(first === second);

const third = await cache('my namespace', true, now);
assert(first !== third && second !== third);
import { cacheSync } from '@axway/amplify-utils';

const now = () => Date.now();

const first = cacheSync('my namespace', now);
const second = cacheSync('my namespace', now);
assert(first === second);

const third = cacheSync('my namespace', true, now);
assert(first !== third && second !== third);

退约者可以取消承诺.

import { debounce } from '@axway/amplify-utils';

const fn = debounce(() => {
    console.log(new Date());
});

// schedule the callback to be called in 200ms
fn().then(() => {
    console.log('Function called');
});

// cancel the debounce
fn.cancel();
import { formatNumber } from '@axway/amplify-utils';

console.log(formatNumber(12)); // 12
console.log(formatNumber(123)); // 123
console.log(formatNumber(1234)); // 1,234
console.log(formatNumber(12345)); // 12,345
console.log(formatNumber(123456)); // 123,456
console.log(formatNumber(1234567)); // 1,234,567
import { get } from '@axway/amplify-utils';

const obj = {
    foo: 'bar'
};

console.log(get(obj, 'foo')); // 'bar'
console.log(get(obj, 'baz', 'pow')); // 'pow'

获得所有打开的套接字、[网 服务器、计时器、儿童流程、文件系统监视器和其他 手柄.

import { getActiveHandles } from '@axway/amplify-utils';

console.log(getActiveHandles());
import { inherits } from '@axway/amplify-utils';

class A {}
class B extends A {}
class C {}

console.log(inherits(B, A)); // true
console.log(inherits(B, C)); // false
import { mergeDeep } from '@axway/amplify-utils';

const obj1 = {
    a: {
        b: 'c'
    }
};

const obj2 = {
    a: {
        d: 'e'
    }
};

console.log(mergeDeep(obj1, obj2)); // { a: { b: 'c', d: 'e' } }
import { mutex } from '@axway/amplify-utils';

const fn = () => {
    return mutex('my mutex', () => {
        console.log('foo!');
    });
};

await Promise.all([ fn(), fn(), fn() ]);
import { randomBytes } from '@axway/amplify-utils';

console.log(randomBytes(20));
import { sha1 } from '@axway/amplify-utils';

console.log(sha1('foo'));
import { sleep } from '@axway/amplify-utils';

await sleep(1000); // sleep for 1 second

屏蔽多个同时呼叫者, 直到第一个呼叫者完成, 然后全部排队“ 尾部启动者 ” 以结果解决.

import { tailgate } from '@axway/amplify-utils';

const fn = () => {
    return tailgate('my tailgate', async () => {
        console.log('I will only be called once');
    });
};

await Promise.all([ fn(), fn(), fn() ]);
import { unique } from '@axway/amplify-utils';

console.log(unique([ 'a', 'b', 'a', 'b' ])); // [ 'a', 'b' ]

此工程在 : Apache 公共许可证 v2 开发者 阿克斯韦公司 与社区。 请读一下 LICENSE 包含文件 在此分发更多信息.

版本与发布记录

@axway/amplify-utils 共发布 34 个版本,首次发布于 2021/09/18;过去 12 个月发布了 3 个版本。

版本发布日期距今
3.0.0latest2026/11/17今天
2.1.02026/03/058 个月前
2.0.62026/01/239 个月前
2.0.52025/07/291.3 年前
2.0.42025/07/291.3 年前
2.0.32025/06/271.4 年前

其他发布通道:next → 1.0.3,alpha.1 → 2.0.0-alpha.1,alpha.2 → 2.0.0-alpha.2,alpha.4 → 2.0.0-alpha.4,alpha.5 → 2.0.0-alpha.5。

关于 @axway/amplify-utils 的常见问题

@axway/amplify-utils 是什么?

Axway 放大工具库

如何安装 @axway/amplify-utils?

在项目目录运行 npm install @axway/amplify-utils,或使用 pnpm add / yarn add / bun add。

@axway/amplify-utils 支持 TypeScript 吗?

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

@axway/amplify-utils 支持 ESM 还是 CommonJS?

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

@axway/amplify-utils 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.13.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@axway/amplify-utils 可以商用吗?

@axway/amplify-utils 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@axway/amplify-utils 的下载量有多少?

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

@axway/amplify-utils 还在维护吗?

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