UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

30 lines (24 loc) 608 B
import { assert } from "../../assert.js"; /** * * @param {string} text * @param {number} cursor * @param {number} limit * @returns {number} */ export function skipWhitespace(text, cursor, limit) { assert.isString(text, 'text'); assert.isNonNegativeInteger(cursor, 'cursor'); assert.isNonNegativeInteger(limit, 'limit'); let i = cursor; let char; while (i < limit) { char = text.charAt(i); if (char === ' ' || char === '\n' || char === '\t') { i++; } else { break; } } return i; }