web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
940 B

  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $TypeError = GetIntrinsic('%TypeError%');
  4. var isPrefixOf = require('../helpers/isPrefixOf');
  5. // var callBound = require('call-bind/callBound');
  6. // var $charAt = callBound('String.prototype.charAt');
  7. var Type = require('./Type');
  8. // https://262.ecma-international.org/9.0/#sec-isstringprefix
  9. module.exports = function IsStringPrefix(p, q) {
  10. if (Type(p) !== 'String') {
  11. throw new $TypeError('Assertion failed: "p" must be a String');
  12. }
  13. if (Type(q) !== 'String') {
  14. throw new $TypeError('Assertion failed: "q" must be a String');
  15. }
  16. return isPrefixOf(p, q);
  17. /*
  18. if (p === q || p === '') {
  19. return true;
  20. }
  21. var pLength = p.length;
  22. var qLength = q.length;
  23. if (pLength >= qLength) {
  24. return false;
  25. }
  26. // assert: pLength < qLength
  27. for (var i = 0; i < pLength; i += 1) {
  28. if ($charAt(p, i) !== $charAt(q, i)) {
  29. return false;
  30. }
  31. }
  32. return true;
  33. */
  34. };