UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

15 lines (14 loc) 564 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.strip = strip; function strip(str) { // parity verified: Ruby 3.3 // discuss at: https://locutus.io/ruby/String/strip/ // original by: Kevin van Zonneveld (https://kvz.io) // note 1: Returns a copy of str with leading and trailing whitespace removed. // example 1: strip(' hello ') // returns 1: 'hello' // example 2: strip('\t\ngoodbye\r\n') // returns 2: 'goodbye' return (str + '').trim(); }