string.prototype.trim
ES5 spec-compliant shim for String.prototype.trim
Last updated a year ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install string.prototype.trim 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.2.8                                ...           latest (a year ago)

13 Versions

  • 1.2.8                                ...           a year ago
  • 1.2.7                                ...           2 years ago
  • 1.2.6                                ...           2 years ago
  • 1.2.5                                ...           3 years ago
  • 1.2.4                                ...           4 years ago
  • 1.2.3                                ...           4 years ago
  • 1.2.2                                ...           4 years ago
  • 1.2.1                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.2                                ...           9 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (12)

Copyright 2013 - present © cnpmjs.org | Home |