string.prototype.trim (1.2.10)

Published 2026-02-24 14:05:39 +00:00 by atheaadmin

Installation

registry=
npm install string.prototype.trim@1.2.10
"string.prototype.trim": "1.2.10"

About this package

String.prototype.trim Version Badge

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

Dependencies

Dependencies

ID Version
call-bind ^1.0.8
call-bound ^1.0.2
define-data-property ^1.1.4
define-properties ^1.2.1
es-abstract ^1.23.5
es-object-atoms ^1.0.0
has-property-descriptors ^1.0.2

Development Dependencies

ID Version
@es-shims/api ^2.5.1
@ljharb/eslint-config ^21.1.1
auto-changelog ^2.5.0
encoding ^0.1.13
eslint =8.8.0
for-each ^0.3.3
functions-have-names ^1.2.3
has-strict-mode ^1.0.1
in-publish ^2.0.1
npmignore ^0.3.1
nyc ^10.3.2
safe-publish-latest ^2.0.0
tape ^5.9.0

Keywords

String.prototype.trim string ES5 shim trim polyfill es-shim API
Details
npm
2026-02-24 14:05:39 +00:00
1
Jordan Harband
MIT
latest
11 KiB
Assets (1)
Versions (1) View all
1.2.10 2026-02-24