isPrefixOf.js 305 B

12345678910111213
  1. 'use strict';
  2. var $strSlice = require('call-bind/callBound')('String.prototype.slice');
  3. module.exports = function isPrefixOf(prefix, string) {
  4. if (prefix === string) {
  5. return true;
  6. }
  7. if (prefix.length > string.length) {
  8. return false;
  9. }
  10. return $strSlice(string, 0, prefix.length) === prefix;
  11. };