MCPcopy Create free account
hub / github.com/ampproject/amphtml / startsWith

Function startsWith

src/polyfills/string-starts-with.js:10–14  ·  view source on GitHub ↗

* Return true if string begins with the characters of the specified string. * Polyfill copied from MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string/startsWith * * @param {string} search * @param {number=} rawPos * @return {boolean} * @this {string}

(search, rawPos)

Source from the content-addressed store, hash-verified

8 * @this {string}
9 */
10function startsWith(search, rawPos) {
11 const pos = rawPos > 0 ? rawPos | 0 : 0;
12 // eslint-disable-next-line local/no-invalid-this
13 return this.substr(pos, search.length) === search;
14}
15
16/**
17 * Sets the String.startsWith polyfill if it does not exist.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected