Files
30-seconds-of-code/node_modules/underscore.string/startsWith.js
2019-08-20 15:52:05 +02:00

10 lines
350 B
JavaScript

var makeString = require('./helper/makeString');
var toPositive = require('./helper/toPositive');
module.exports = function startsWith(str, starts, position) {
str = makeString(str);
starts = '' + starts;
position = position == null ? 0 : Math.min(toPositive(position), str.length);
return str.lastIndexOf(starts, position) === position;
};