String.prototype.trim <sup>Version Badge</sup>

github actions coverage dependency status dev dependency status License Downloads

![npm badge][npm-badge-png]

An ES5 spec-compliant String.prototype.trim shim. Invoke its "shim" method to shim String.prototype.trim if it is unavailable.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec (both ES5 and current).

Most common usage:

var assert = require('assert');
var trim = require('string.prototype.trim');

assert(trim(' \t\na \t\n') === 'a');

trim.shim(); // will be a no-op if not needed

assert(trim(' \t\na \t\n') === ' \t\na \t\n'.trim());

Engine Bugs

Some implementations of String#trim incorrectly trim zero-width spaces. This shim detects and corrects this behavior.

Tests

Simply clone the repo, npm install, and run npm test

string.prototype.trim - Installation

To install string.prototype.trim via this registry, you'll need to install via the --registry parameter with your package manager.

n

NPM

npm install string.prototype.trim --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Yarn

yarn config set registry https://js.registry.sudovanilla.org
yarn install string.prototype.trim

Learn more about the config option.

PNPM

pnpm install string.prototype.trim --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Bun Logo

Bun

bun install string.prototype.trim --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Learn more about setting this up in your bunfig.toml configuration.


For Deno, add the following to your .npmrc file in your directory:

registry="https://js.registry.sudovanilla.org"

Then run the deno install command.

string.prototype.trim - Download

Download Tarball (v1.2.10)

Integrity sha512-Rs66F0P/1kedk5lyYyH9uBzuiI/kNRmwJAR9quK6VOtIpZ2G+hMZd+HQbbv25MgCA6gEffoMZYxlTod4WcdrKA==
SHASUM 40b2dd5ee94c959b4dcfb1d65ce72e90da480c81
Tarball https://js.registry.sudovanilla.org/string.prototype.trim/-/string.prototype.trim-1.2.10.tgz