UNPKG

locutus

Version:

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

17 lines (16 loc) 600 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TrimPrefix = TrimPrefix; function TrimPrefix(s, prefix) { // discuss at: https://locutus.io/golang/strings/TrimPrefix/ // parity verified: Go 1.23 // original by: Kevin van Zonneveld (https://kvz.io) // example 1: TrimPrefix('Hello, World!', 'Hello, ') // returns 1: 'World!' // example 2: TrimPrefix('Hello, World!', 'Goodbye, ') // returns 2: 'Hello, World!' if (s.startsWith(prefix)) { return s.slice(prefix.length); } return s; }