mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-28 00:45:04 +08:00
Bug: 370734442 No-Presubmit: true Change-Id: I7021b801e5bacd4ed33643651a53b8db20ccf8b0 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5898986 Commit-Queue: Danil Somsikov <dsv@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org>
82 lines
2.6 KiB
JavaScript
82 lines
2.6 KiB
JavaScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
(function (factory) {
|
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
var v = factory(require, exports);
|
|
if (v !== undefined) module.exports = v;
|
|
}
|
|
else if (typeof define === "function" && define.amd) {
|
|
define(["require", "exports"], factory);
|
|
}
|
|
})(function (require, exports) {
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
function startsWith(haystack, needle) {
|
|
if (haystack.length < needle.length) {
|
|
return false;
|
|
}
|
|
for (var i = 0; i < needle.length; i++) {
|
|
if (haystack[i] !== needle[i]) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
exports.startsWith = startsWith;
|
|
/**
|
|
* Determines if haystack ends with needle.
|
|
*/
|
|
function endsWith(haystack, needle) {
|
|
var diff = haystack.length - needle.length;
|
|
if (diff > 0) {
|
|
return haystack.lastIndexOf(needle) === diff;
|
|
}
|
|
else if (diff === 0) {
|
|
return haystack === needle;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
exports.endsWith = endsWith;
|
|
/**
|
|
* @returns the length of the common prefix of the two strings.
|
|
*/
|
|
function commonPrefixLength(a, b) {
|
|
var i;
|
|
var len = Math.min(a.length, b.length);
|
|
for (i = 0; i < len; i++) {
|
|
if (a.charCodeAt(i) !== b.charCodeAt(i)) {
|
|
return i;
|
|
}
|
|
}
|
|
return len;
|
|
}
|
|
exports.commonPrefixLength = commonPrefixLength;
|
|
function repeat(value, count) {
|
|
var s = '';
|
|
while (count > 0) {
|
|
if ((count & 1) === 1) {
|
|
s += value;
|
|
}
|
|
value += value;
|
|
count = count >>> 1;
|
|
}
|
|
return s;
|
|
}
|
|
exports.repeat = repeat;
|
|
var _a = 'a'.charCodeAt(0);
|
|
var _z = 'z'.charCodeAt(0);
|
|
var _A = 'A'.charCodeAt(0);
|
|
var _Z = 'Z'.charCodeAt(0);
|
|
var _0 = '0'.charCodeAt(0);
|
|
var _9 = '9'.charCodeAt(0);
|
|
function isLetterOrDigit(text, index) {
|
|
var c = text.charCodeAt(index);
|
|
return (_a <= c && c <= _z) || (_A <= c && c <= _Z) || (_0 <= c && c <= _9);
|
|
}
|
|
exports.isLetterOrDigit = isLetterOrDigit;
|
|
});
|