Package Exports
- @nevware21/ts-utils
- @nevware21/ts-utils/dist-esm/index.js
- @nevware21/ts-utils/dist/umd/ts-utils.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@nevware21/ts-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@nevware21 ts-utils
Common JavaScript/TypeScript helper functions for better minification
Description
This is a collection of general JavaScript functions (written in and for TypeScript) to aid with removing code duplication to assist with minification, the provided functions are expected to only rarely be included in their namespaced environment.
Support for standard JavaScript functions (ES5+) that are not support in all environments will be backed by internal polyfill implementations when not available. All of the polyfill functions are tested against the standard native implementations for node, browser and web-worker to ensure compatibility.
Documentation and details
Documentation generated from source code via typedoc
Some polyfills are provided for simple backward compatability to enable the utility functions in older environments (such as ES3 / IE8), you don't have to use or include the provided polyfils (AND they are NOT exported as part of the main module). If you need them you will need to import the "polyfill" file directly or host and load the provided bundle/ts-polyfills-utils.min.js
or provide your own alternatives.
See Browser Support for details.
Quickstart
Install the npm packare: npm install @nevware21/ts-utils --save
And then just import the helpers and use them.
import { isArray, arrForEach, objForEachKey, objHasOwnProperty } from "@nevware21/ts-utils";
export function simpleTest(theValue: any): string[] {
let result: any[] = [];
if (isArray(theValue)) {
arrForEach(theValue, (value, idx) => {
if (objHasOwnProperty(theValue, value)) {
result.push(idx + ":" + value);
}
});
} else {
objForEachKey(theValue, (key, value) => {
if (value) {
result.push(key + "=" + value);
}
});
}
return result;
}
Or checking if a variable is a string
import { isString } from "@nevware21/ts-utils";
function checkString(value: any) {
let ug = 1;
return isString(value);
}
Browser Support
General support is currently set to ES5 supported runtimes higher.
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
Latest ? | Latest ? | 9+ Full ? 8- polyfills needed |
Latest ? | Latest ? |
Note: While some polyfills are provided to "somewhat" support ES3/IE8 this library does not intend to become a fully fledged polyfill library. And the polyfills provided (or contributed) are just the minimum set that have been required over time. And should be less necessary are time moves forward.
Contributing
Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes.