All Projects → es-shims → String.prototype.trim

es-shims / String.prototype.trim

Licence: MIT license
ES5 spec-compliant shim for String.prototype.trim

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to String.prototype.trim

String.prototype.matchAll
Spec-compliant polyfill for String.prototype.matchAll, in ES2020
Stars: ✭ 14 (+7.69%)
Mutual labels:  polyfill, string, shim
str
str is a string module with useful methods that don't exist in Lua's core
Stars: ✭ 30 (+130.77%)
Mutual labels:  string, trim
barcode-detector
Spec compliant polyfill of the Barcode Detection API 🤳
Stars: ✭ 31 (+138.46%)
Mutual labels:  polyfill, shim
Object.getOwnPropertyDescriptors
Spec-compliant shim for `Object.getOwnPropertyDescriptors` that works in ES5.
Stars: ✭ 19 (+46.15%)
Mutual labels:  polyfill, shim
Array.prototype.at
An ES-spec-compliant (proposed) `Array.prototype.at`shim/polyfill/replacement that works as far down as ES3.
Stars: ✭ 20 (+53.85%)
Mutual labels:  polyfill, shim
object-keys
Object.keys shim
Stars: ✭ 41 (+215.38%)
Mutual labels:  polyfill, shim
Promise.allSettled
ES Proposal spec-compliant shim for Promise.allSettled
Stars: ✭ 93 (+615.38%)
Mutual labels:  polyfill, shim
Core Js
Standard Library
Stars: ✭ 15,854 (+121853.85%)
Mutual labels:  polyfill, shim
array-includes
Array.prototype.includes spec-compliant polyfill
Stars: ✭ 42 (+223.08%)
Mutual labels:  polyfill, shim
react-native-console-time-polyfill
console.time and console.timeEnd polyfill for react-native
Stars: ✭ 92 (+607.69%)
Mutual labels:  polyfill
react-native-audio-polyfill
Audio polyfill for desktop and native.
Stars: ✭ 13 (+0%)
Mutual labels:  polyfill
parse-author
Parse a person, author, contributor or maintainer string into an object with name, email and url properties following NPM conventions. Useful for the `authors` property in package.json or for parsing an AUTHORS file into an array of person objects.
Stars: ✭ 23 (+76.92%)
Mutual labels:  string
html-comment-regex
Regular expression for matching HTML comments
Stars: ✭ 15 (+15.38%)
Mutual labels:  string
textics
📉 JavaScript Text Statistics that counts lines, words, chars, and spaces.
Stars: ✭ 36 (+176.92%)
Mutual labels:  string
TairString
A redis module, similar to redis string, but you can set expire and version for the value. It also provides many very useful commands, such as cas/cad, etc.
Stars: ✭ 99 (+661.54%)
Mutual labels:  string
Competitive Programming
Programming👨‍💻 Questions on BinarySearch💻, LeetCode💻, CodeChef💻, Codeforces💻,DSA 450
Stars: ✭ 188 (+1346.15%)
Mutual labels:  string
draggable-polyfill
🌈a beautify polyfill for native drag!
Stars: ✭ 49 (+276.92%)
Mutual labels:  polyfill
PHPUnit-Polyfills
Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests
Stars: ✭ 147 (+1030.77%)
Mutual labels:  polyfill
sanitizer-polyfill
rewrite constructor arguments, call DOMPurify, profit
Stars: ✭ 46 (+253.85%)
Mutual labels:  polyfill
is-primitive
Is the typeof value a javascript primitive?
Stars: ✭ 35 (+169.23%)
Mutual labels:  string

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].