Revamping to matrix style
This commit is contained in:
70
node_modules/vscode-json-languageservice/lib/umd/utils/strings.js
generated
vendored
Normal file
70
node_modules/vscode-json-languageservice/lib/umd/utils/strings.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 });
|
||||
exports.extendedRegExp = exports.repeat = exports.convertSimple2RegExpPattern = exports.endsWith = exports.startsWith = void 0;
|
||||
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;
|
||||
function convertSimple2RegExpPattern(pattern) {
|
||||
return pattern.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&').replace(/[\*]/g, '.*');
|
||||
}
|
||||
exports.convertSimple2RegExpPattern = convertSimple2RegExpPattern;
|
||||
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;
|
||||
function extendedRegExp(pattern) {
|
||||
if (startsWith(pattern, '(?i)')) {
|
||||
return new RegExp(pattern.substring(4), 'i');
|
||||
}
|
||||
else {
|
||||
return new RegExp(pattern);
|
||||
}
|
||||
}
|
||||
exports.extendedRegExp = extendedRegExp;
|
||||
});
|
||||
Reference in New Issue
Block a user