source: imaps-frontend/node_modules/es-abstract/2017/SplitMatch.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 803 bytes
Line 
1'use strict';
2
3var callBound = require('call-bound');
4
5var $TypeError = require('es-errors/type');
6var isInteger = require('math-intrinsics/isInteger');
7
8var $charAt = callBound('String.prototype.charAt');
9
10// https://262.ecma-international.org/6.0/#sec-splitmatch
11
12module.exports = function SplitMatch(S, q, R) {
13 if (typeof S !== 'string') {
14 throw new $TypeError('Assertion failed: `S` must be a String');
15 }
16 if (!isInteger(q)) {
17 throw new $TypeError('Assertion failed: `q` must be an integer');
18 }
19 if (typeof R !== 'string') {
20 throw new $TypeError('Assertion failed: `R` must be a String');
21 }
22 var r = R.length;
23 var s = S.length;
24 if (q + r > s) {
25 return false;
26 }
27
28 for (var i = 0; i < r; i += 1) {
29 if ($charAt(S, q + i) !== $charAt(R, i)) {
30 return false;
31 }
32 }
33
34 return q + r;
35};
Note: See TracBrowser for help on using the repository browser.