@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 821 B
JavaScript
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
import r from"./../assert/is-integer.js";import e from"./../assert/is-string.js";var t=r.isPrimitive,i=e.isPrimitive;function n(r,e,n){var a,s;if(!i(r))throw new TypeError("invalid argument. First argument must be a string primitive. Value: `"+r+"`.");if(!i(e))throw new TypeError("invalid argument. Second argument must be a string primitive. Value: `"+e+"`.");if(arguments.length>2){if(!t(n))throw new TypeError("invalid argument. Third argument must be an integer. Value: `"+n+"`.");a=n<0?r.length+n:n}else a=0;if(0===e.length)return!0;if(a<0||a+e.length>r.length)return!1;for(s=0;s<e.length;s++)if(r.charCodeAt(a+s)!==e.charCodeAt(s))return!1;return!0}var a=n;export default a;
//# sourceMappingURL=starts-with.js.map