npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@axway/amplify-utils

v1.0.15

Published

Axway Amplify utility library

Downloads

9,859

Readme

Amplify Utils

A library for solving common filesystem, path, and more.

Installation

npm i @axway/amplify-utils --save

fs

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));

path

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'));

utils

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);

Debouncer that returns a promise and that can be cancelled.

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'

Get all open sockets, [net] servers, timers, child processes, filesystem watchers, and other handles.

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

Block multiple simultaneous callers until the first caller finishes, then all queued up 'tailgaters' are resolved with the result.

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' ]

Legal

This project is open source under the Apache Public License v2 and is developed by Axway, Inc and the community. Please read the LICENSE file included in this distribution for more information.