@wixc3/common
Advanced tools
Comparing version 5.1.0 to 5.2.3
@@ -23,5 +23,4 @@ "use strict"; | ||
class ErrorWithCode extends Error { | ||
code; | ||
constructor(message, options) { | ||
const { code, ...nativeErrorOptions } = options ?? {}; | ||
const { code, ...nativeErrorOptions } = options !== null && options !== void 0 ? options : {}; | ||
super(message, nativeErrorOptions); | ||
@@ -28,0 +27,0 @@ this.code = code; |
@@ -59,3 +59,4 @@ "use strict"; | ||
if (index < 0) { | ||
return Array.from(iterable).at(index); | ||
const iterAsArray = Array.from(iterable); | ||
return iterAsArray[iterAsArray.length + index]; | ||
} | ||
@@ -62,0 +63,0 @@ let i = 0; |
@@ -94,3 +94,3 @@ "use strict"; | ||
if (value) { | ||
reversedObject[value] ||= key; | ||
reversedObject[value] || (reversedObject[value] = key); | ||
} | ||
@@ -172,3 +172,3 @@ } | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
return path.reduce((value, key) => value?.[key], obj); | ||
return path.reduce((value, key) => value === null || value === void 0 ? void 0 : value[key], obj); | ||
} | ||
@@ -175,0 +175,0 @@ exports.getIn = getIn; |
@@ -9,6 +9,6 @@ "use strict"; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access | ||
const platform = _process?.platform; | ||
exports.isMac = platform ? platform === 'darwin' : _navigator?.platform.includes('Mac'); | ||
exports.isWindows = platform ? platform === 'win32' : _navigator?.platform.includes('Win32'); | ||
exports.isElectronRendererProcess = typeof _process === 'object' && _process?.type === 'renderer'; | ||
const platform = _process === null || _process === void 0 ? void 0 : _process.platform; | ||
exports.isMac = platform ? platform === 'darwin' : _navigator === null || _navigator === void 0 ? void 0 : _navigator.platform.includes('Mac'); | ||
exports.isWindows = platform ? platform === 'win32' : _navigator === null || _navigator === void 0 ? void 0 : _navigator.platform.includes('Win32'); | ||
exports.isElectronRendererProcess = typeof _process === 'object' && (_process === null || _process === void 0 ? void 0 : _process.type) === 'renderer'; | ||
const getOs = () => { | ||
@@ -19,14 +19,14 @@ if (platform) { | ||
/** Normilizes return value to nodejs output */ | ||
if (_navigator?.platform.includes('Mac')) { | ||
if (_navigator === null || _navigator === void 0 ? void 0 : _navigator.platform.includes('Mac')) { | ||
return 'darwin'; | ||
} | ||
if (_navigator?.platform.includes('Win')) { | ||
if (_navigator === null || _navigator === void 0 ? void 0 : _navigator.platform.includes('Win')) { | ||
return 'win32'; | ||
} | ||
if (_navigator?.platform.includes('Linux')) { | ||
if (_navigator === null || _navigator === void 0 ? void 0 : _navigator.platform.includes('Linux')) { | ||
return 'linux'; | ||
} | ||
return _navigator?.platform; | ||
return _navigator === null || _navigator === void 0 ? void 0 : _navigator.platform; | ||
}; | ||
exports.getOs = getOs; | ||
//# sourceMappingURL=platform.js.map |
@@ -21,3 +21,4 @@ "use strict"; | ||
const escapeCSS = (str) => str.replace(/\W/giu, (char) => { | ||
const code = char.codePointAt(0) ?? 0xfffd; | ||
var _a; | ||
const code = (_a = char.codePointAt(0)) !== null && _a !== void 0 ? _a : 0xfffd; | ||
return `\\${code.toString(16)} `; | ||
@@ -66,3 +67,4 @@ }); | ||
const splitIntoWords = (str) => { | ||
let words = str.match(/[a-z0-9]+/gi) ?? []; | ||
var _a; | ||
let words = (_a = str.match(/[a-z0-9]+/gi)) !== null && _a !== void 0 ? _a : []; | ||
words = words.flatMap((w) => w.split(/(\d+)/g)); // Numbers | ||
@@ -246,3 +248,3 @@ words = words.flatMap((w) => w.split(/([A-Z]+)(?=[A-Z][a-z])/g)); // Acronyms | ||
.split('\n') | ||
.map((line) => line.replaceAll(/\s+/g, ' ').trim()) | ||
.map((line) => line.replace(/\s+/g, ' ').trim()) | ||
.filter((i) => i) | ||
@@ -298,5 +300,5 @@ .join('\n'); | ||
function naiveStripComments(str) { | ||
return str.replaceAll(/\/\*.+?\*\//gs, '').replaceAll(/\s*(?<!:)\/\/.*\n?/g, ''); | ||
return str.replace(/\/\*.+?\*\//gs, '').replace(/\s*(?<!:)\/\/.*\n?/g, ''); | ||
} | ||
exports.naiveStripComments = naiveStripComments; | ||
//# sourceMappingURL=strings.js.map |
@@ -18,5 +18,4 @@ import { isPlainObject } from './objects'; | ||
export class ErrorWithCode extends Error { | ||
code; | ||
constructor(message, options) { | ||
const { code, ...nativeErrorOptions } = options ?? {}; | ||
const { code, ...nativeErrorOptions } = options !== null && options !== void 0 ? options : {}; | ||
super(message, nativeErrorOptions); | ||
@@ -23,0 +22,0 @@ this.code = code; |
@@ -52,3 +52,4 @@ import { isDefined } from './types'; | ||
if (index < 0) { | ||
return Array.from(iterable).at(index); | ||
const iterAsArray = Array.from(iterable); | ||
return iterAsArray[iterAsArray.length + index]; | ||
} | ||
@@ -55,0 +56,0 @@ let i = 0; |
@@ -82,3 +82,3 @@ import { sleep } from 'promise-assist'; | ||
if (value) { | ||
reversedObject[value] ||= key; | ||
reversedObject[value] || (reversedObject[value] = key); | ||
} | ||
@@ -158,3 +158,3 @@ } | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
return path.reduce((value, key) => value?.[key], obj); | ||
return path.reduce((value, key) => value === null || value === void 0 ? void 0 : value[key], obj); | ||
} | ||
@@ -161,0 +161,0 @@ const DELETE = Symbol(); |
@@ -6,6 +6,6 @@ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access | ||
const platform = _process?.platform; | ||
export const isMac = platform ? platform === 'darwin' : _navigator?.platform.includes('Mac'); | ||
export const isWindows = platform ? platform === 'win32' : _navigator?.platform.includes('Win32'); | ||
export const isElectronRendererProcess = typeof _process === 'object' && _process?.type === 'renderer'; | ||
const platform = _process === null || _process === void 0 ? void 0 : _process.platform; | ||
export const isMac = platform ? platform === 'darwin' : _navigator === null || _navigator === void 0 ? void 0 : _navigator.platform.includes('Mac'); | ||
export const isWindows = platform ? platform === 'win32' : _navigator === null || _navigator === void 0 ? void 0 : _navigator.platform.includes('Win32'); | ||
export const isElectronRendererProcess = typeof _process === 'object' && (_process === null || _process === void 0 ? void 0 : _process.type) === 'renderer'; | ||
export const getOs = () => { | ||
@@ -16,13 +16,13 @@ if (platform) { | ||
/** Normilizes return value to nodejs output */ | ||
if (_navigator?.platform.includes('Mac')) { | ||
if (_navigator === null || _navigator === void 0 ? void 0 : _navigator.platform.includes('Mac')) { | ||
return 'darwin'; | ||
} | ||
if (_navigator?.platform.includes('Win')) { | ||
if (_navigator === null || _navigator === void 0 ? void 0 : _navigator.platform.includes('Win')) { | ||
return 'win32'; | ||
} | ||
if (_navigator?.platform.includes('Linux')) { | ||
if (_navigator === null || _navigator === void 0 ? void 0 : _navigator.platform.includes('Linux')) { | ||
return 'linux'; | ||
} | ||
return _navigator?.platform; | ||
return _navigator === null || _navigator === void 0 ? void 0 : _navigator.platform; | ||
}; | ||
//# sourceMappingURL=platform.js.map |
@@ -17,3 +17,4 @@ import { getIn } from './objects'; | ||
export const escapeCSS = (str) => str.replace(/\W/giu, (char) => { | ||
const code = char.codePointAt(0) ?? 0xfffd; | ||
var _a; | ||
const code = (_a = char.codePointAt(0)) !== null && _a !== void 0 ? _a : 0xfffd; | ||
return `\\${code.toString(16)} `; | ||
@@ -59,3 +60,4 @@ }); | ||
export const splitIntoWords = (str) => { | ||
let words = str.match(/[a-z0-9]+/gi) ?? []; | ||
var _a; | ||
let words = (_a = str.match(/[a-z0-9]+/gi)) !== null && _a !== void 0 ? _a : []; | ||
words = words.flatMap((w) => w.split(/(\d+)/g)); // Numbers | ||
@@ -226,3 +228,3 @@ words = words.flatMap((w) => w.split(/([A-Z]+)(?=[A-Z][a-z])/g)); // Acronyms | ||
.split('\n') | ||
.map((line) => line.replaceAll(/\s+/g, ' ').trim()) | ||
.map((line) => line.replace(/\s+/g, ' ').trim()) | ||
.filter((i) => i) | ||
@@ -274,4 +276,4 @@ .join('\n'); | ||
export function naiveStripComments(str) { | ||
return str.replaceAll(/\/\*.+?\*\//gs, '').replaceAll(/\s*(?<!:)\/\/.*\n?/g, ''); | ||
return str.replace(/\/\*.+?\*\//gs, '').replace(/\s*(?<!:)\/\/.*\n?/g, ''); | ||
} | ||
//# sourceMappingURL=strings.js.map |
{ | ||
"name": "@wixc3/common", | ||
"version": "5.1.0", | ||
"version": "5.2.3", | ||
"description": "Common utils, usable in all environments", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -61,3 +61,4 @@ import { isDefined, Nullable } from './types'; | ||
if (index < 0) { | ||
return Array.from(iterable).at(index); | ||
const iterAsArray = Array.from(iterable); | ||
return iterAsArray[iterAsArray.length + index]; | ||
} | ||
@@ -64,0 +65,0 @@ let i = 0; |
@@ -252,3 +252,3 @@ import { getIn } from './objects'; | ||
.split('\n') | ||
.map((line) => line.replaceAll(/\s+/g, ' ').trim()) | ||
.map((line) => line.replace(/\s+/g, ' ').trim()) | ||
.filter((i) => i) | ||
@@ -304,3 +304,3 @@ .join('\n'); | ||
export function naiveStripComments(str: string) { | ||
return str.replaceAll(/\/\*.+?\*\//gs, '').replaceAll(/\s*(?<!:)\/\/.*\n?/g, ''); | ||
return str.replace(/\/\*.+?\*\//gs, '').replace(/\s*(?<!:)\/\/.*\n?/g, ''); | ||
} |
@@ -7,2 +7,4 @@ import { expect } from 'chai'; | ||
const timer = typeof performance !== 'undefined' ? performance : Date; | ||
describe('performance', () => { | ||
@@ -12,3 +14,3 @@ it('it faster than the array equivalent function for large iterables', () => { | ||
forceGc(); | ||
const arrayStart = performance.now(); | ||
const arrayStart = timer.now(); | ||
const result = veryLargeArray | ||
@@ -27,5 +29,5 @@ .map((i) => i - 10_000) | ||
forceGc(); | ||
const arrayTime = performance.now() - arrayStart; | ||
const arrayTime = timer.now() - arrayStart; | ||
const iterStart = performance.now(); | ||
const iterStart = timer.now(); | ||
const iterResult = chain(veryLargeArray) | ||
@@ -39,3 +41,3 @@ .map((i) => i - 10_000) | ||
forceGc(); | ||
const iterTime = performance.now() - iterStart; | ||
const iterTime = timer.now() - iterStart; | ||
@@ -42,0 +44,0 @@ expect([...result]).to.eql([...iterResult]); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
337432
6064