Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vuedx/shared

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vuedx/shared - npm Package Compare versions

Comparing version 0.7.4-insiders-1623402835.0 to 0.7.4-insiders-1630600136.0

68

lib/index.d.ts

@@ -12,5 +12,59 @@ /**

declare function findNextSibling<T>(items: T[] | readonly T[], item: T): T | undefined;
declare function concat<T>(a: T[] | undefined, b: T[] | undefined): T[];
declare function flatten<T>(array: Array<T | T[]>, depth?: number): T[];
declare function concat<T>(a: T[] | Readonly<T[]> | undefined, b: T[] | Readonly<T[]> | undefined): T[];
declare type FlatArray<Arr, Depth extends number> = {
done: Arr;
recur: Arr extends ReadonlyArray<infer InnerArr> ? FlatArray<InnerArr, [
-1,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
][Depth]> : Arr;
}[Depth extends -1 ? 'done' : 'recur'];
declare function flatten<T extends unknown, D extends number = 1>(array: T, depth?: D): Array<FlatArray<T, D>>;
interface Cache<K, V> {
has(key: K): boolean;
get(key: K): V | undefined;
set(key: K, value: V): void;
delete(key: K): void;
clear(): void;
resolve(key: K, getter: (key: K) => V): V;
resolveAsync(key: K, getter: (key: K) => Promise<V>): Promise<V>;
}
declare function createCache<K, V>(size?: number): Cache<K, V>;
declare function createWeakMapCache<K extends object, V>(): Cache<K, V>;
declare function createMultiKeyCache<K, V, R = unknown>(getSecondaryKey: (key: K) => R, size?: number, compare?: (a: R, b: R) => boolean): Cache<K, V>;
declare function createVersionedCache<K, V, Version extends string | number = string | number>(getVersion: (key: K) => Version, size?: number): Cache<K, V>;
declare function versionedAsync<T extends unknown[], R = unknown>(getKey?: (args: T) => R, size?: number, versionFn?: unknown & string): MethodDecorator;
declare function versioned<T extends unknown[], R = unknown>(getKey?: (args: T) => R, size?: number, versionFn?: unknown & string, isAsync?: boolean): MethodDecorator;
/**
* Cache returned value from function.
*
* By default, it uses a "least recently used" or LRU cache
* of size 100.
*/
declare function cache<T extends unknown[], R = unknown>(getKey?: (args: T) => R, isAsync?: boolean, isWeak?: boolean): MethodDecorator;
declare function cacheAsync<T extends unknown[], R = unknown>(getKey?: (args: T) => R): MethodDecorator;
declare function cacheAll<T extends unknown[], R = unknown>(getKey?: (args: T) => R): MethodDecorator;
declare function cacheAllAsync<T extends unknown[], R = unknown>(getKey?: (args: T) => R): MethodDecorator;
declare function clearMethodCache(instance: object, propertyKey: string | symbol | number): void;
declare function getComponentName(fileName: string): string;

@@ -21,2 +75,5 @@ declare function getComponentNameAliases(fileNameOrComponentName: string): string[];

declare function toPosixPath(path: string): string;
declare function toWindowsPath(path: string): string;
declare const toPlatformPath: typeof toWindowsPath;
declare function getRelativeFileName(importingFileName: string, importedFileName: string): string;

@@ -56,2 +113,3 @@

private getUserId;
measure(_name: string, _duration: number): void;
trace(name: string, description?: string): () => void;

@@ -71,2 +129,6 @@ collect(key: string, value: Record<string, any>): void;

export { Telemetry, camelCase, camelize, capitalize, collect, collectError, concat, findNextSibling, findPrevSibling, first, flatten, getComponentName, getComponentNameAliases, getRelativeFileName, hyphenate, isArray, isCamelCase, isKebabCase, isNotNull, isNumber, isPascalCase, isString, kebabCase, last, pascalCase, trace, tracePromise, uncapitalize };
declare type DeepPartial<T> = T extends {} ? {
[P in keyof T]?: DeepPartial<T[P]>;
} : T;
export { Cache, DeepPartial, Telemetry, cache, cacheAll, cacheAllAsync, cacheAsync, camelCase, camelize, capitalize, clearMethodCache, collect, collectError, concat, createCache, createMultiKeyCache, createVersionedCache, createWeakMapCache, findNextSibling, findPrevSibling, first, flatten, getComponentName, getComponentNameAliases, getRelativeFileName, hyphenate, isArray, isCamelCase, isKebabCase, isNotNull, isNumber, isPascalCase, isString, kebabCase, last, pascalCase, toPlatformPath, toPosixPath, toWindowsPath, trace, tracePromise, uncapitalize, versioned, versionedAsync };

@@ -6,5 +6,5 @@ 'use strict';

const Path = require('path');
const OS = require('os');
const Sentry = require('@sentry/node');
const nodeUniqueMachineId = require('node-unique-machine-id');
const os = require('os');
const util = require('util');

@@ -33,2 +33,3 @@

const Path__namespace = /*#__PURE__*/_interopNamespace(Path);
const OS__namespace = /*#__PURE__*/_interopNamespace(OS);
const Sentry__namespace = /*#__PURE__*/_interopNamespace(Sentry);

@@ -64,3 +65,4 @@

return items[index - 1];
return undefined;
else
return undefined;
}

@@ -71,3 +73,4 @@ function findNextSibling(items, item) {

return items[index + 1];
return undefined;
else
return undefined;
}

@@ -84,15 +87,231 @@ function concat(a, b) {

const items = [];
array.forEach((item) => {
if (Array.isArray(item)) {
if (depth > 0)
items.push(...flatten(item, depth - 1));
else
items.push(...item);
if (Array.isArray(array)) {
array.forEach((item) => {
if (Array.isArray(item)) {
if (depth > 1)
items.push(...flatten(item, depth - 1));
else
items.push(...item);
}
else {
items.push(item);
}
});
}
return items;
}
class BaseCache {
constructor() {
this.promises = new Map();
}
resolve(key, getter) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (this.has(key))
return this.get(key);
const value = getter(key);
this.set(key, value);
return value;
}
async resolveAsync(key, getter) {
var _a;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (this.has(key))
return this.get(key);
const promise = (_a = this.promises.get(key)) !== null && _a !== void 0 ? _a : getter(key);
this.promises.set(key, promise);
try {
const value = await promise;
this.set(key, value);
return value;
}
finally {
this.promises.delete(key);
}
}
}
class LRU extends BaseCache {
constructor(maxSize) {
super();
this.maxSize = maxSize;
this.current = new Map();
this.previous = new Map();
}
has(key) {
return this.current.has(key) || this.previous.has(key);
}
get(key) {
if (this.current.has(key))
return this.current.get(key);
else if (this.previous.has(key)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const value = this.previous.get(key);
this.set(key, value);
return value;
}
else
return undefined;
}
set(key, value) {
this.current.set(key, value);
if (this.current.size > this.maxSize) {
this.previous = this.current;
this.current = new Map();
}
}
delete(key) {
this.current.delete(key);
this.previous.delete(key);
}
clear() {
this.current.clear();
this.previous.clear();
}
}
class WeakCache extends BaseCache {
constructor() {
super(...arguments);
this.storage = new WeakMap();
}
has(key) {
return this.storage.has(key);
}
get(key) {
return this.storage.get(key);
}
set(key, value) {
this.storage.set(key, value);
}
delete(key) {
this.storage.delete(key);
}
clear() {
this.storage = new WeakMap();
}
}
class VersionedCache extends BaseCache {
constructor(size, getVersion, compareVersion) {
super();
this.getVersion = getVersion;
this.compareVersion = compareVersion;
this.storage = new LRU(size);
}
isValid(key, value) {
return this.compareVersion(value.version, this.getVersion(key));
}
has(key) {
return this.storage.has(key) && this.isValid(key, this.storage.get(key));
}
get(key) {
if (this.has(key))
return this.storage.get(key).value;
else
return undefined;
}
set(key, value) {
this.storage.set(key, { version: this.getVersion(key), value });
}
delete(key) {
this.storage.delete(key);
}
clear() {
this.storage.clear();
}
}
const DEFAULT_CACHE_SIZE = 100;
function createCache(size = DEFAULT_CACHE_SIZE) {
return new LRU(size);
}
function createWeakMapCache() {
return new WeakCache();
}
function createMultiKeyCache(getSecondaryKey, size = DEFAULT_CACHE_SIZE, compare = (a, b) => a === b) {
return new VersionedCache(size, (key) => getSecondaryKey(key), compare);
}
function createVersionedCache(getVersion, size = DEFAULT_CACHE_SIZE) {
return createMultiKeyCache(getVersion, size);
}
function versionedAsync(getKey = (args) => args[0], size = DEFAULT_CACHE_SIZE, versionFn = 'getVersion') {
return versioned(getKey, size, versionFn, true);
}
const store = new Map();
function addToStore(target, property, cache) {
var _a;
const current = (_a = store.get(target)) !== null && _a !== void 0 ? _a : new Map();
current.set(property, cache);
if (!store.has(target))
store.set(target, current);
}
function getOrCreate(map, create) {
return (key) => {
var _a;
const value = (_a = map.get(key)) !== null && _a !== void 0 ? _a : create(key);
if (!map.has(key))
map.set(key, value);
return value;
};
}
function versioned(getKey = (args) => args[0], size = DEFAULT_CACHE_SIZE, versionFn = 'getVersion', isAsync = false) {
const method = isAsync ? 'resolveAsync' : 'resolve';
return (target, propertyKey, descriptor) => {
const fn = descriptor === null || descriptor === void 0 ? void 0 : descriptor.value;
if (typeof fn === 'function') {
const caches = new WeakMap();
const using = getOrCreate(caches, (instance) => {
const getVersion = instance[versionFn];
if (typeof getVersion !== 'function')
throw new Error(`${JSON.stringify(versionFn)} is not a function`);
return createVersionedCache((key) => getVersion.call(instance, key), size);
});
addToStore(target, propertyKey, caches);
descriptor.value = function (...args) {
return using(this)[method](getKey(args), () => fn.apply(this, args));
};
}
else {
items.push(item);
throw new Error(`${JSON.stringify(propertyKey)} is not a function`);
}
});
return items;
return descriptor;
};
}
/**
* Cache returned value from function.
*
* By default, it uses a "least recently used" or LRU cache
* of size 100.
*/
function cache(getKey = (args) => args[0], isAsync = false, isWeak = false) {
const method = isAsync ? 'resolveAsync' : 'resolve';
return (target, propertyKey, descriptor) => {
const fn = descriptor === null || descriptor === void 0 ? void 0 : descriptor.value;
if (typeof fn === 'function') {
const caches = new WeakMap();
addToStore(target, propertyKey, caches);
const using = getOrCreate(caches, () => {
return isWeak ? createWeakMapCache() : createCache(DEFAULT_CACHE_SIZE);
});
descriptor.value = function (...args) {
return using(this)[method](getKey(args), () => fn.apply(this, args));
};
}
else {
throw new Error(`${JSON.stringify(propertyKey)} is not a function`);
}
return descriptor;
};
}
function cacheAsync(getKey = (args) => args[0]) {
return cache(getKey, true);
}
function cacheAll(getKey = (args) => args[0]) {
return cache(getKey, false, true);
}
function cacheAllAsync(getKey = (args) => args[0]) {
return cache(getKey, true, true);
}
function clearMethodCache(instance, propertyKey) {
var _a, _b, _c;
const target = Object.getPrototypeOf(instance);
(_c = (_b = (_a = store.get(target)) === null || _a === void 0 ? void 0 : _a.get(propertyKey)) === null || _b === void 0 ? void 0 : _b.get(instance)) === null || _c === void 0 ? void 0 : _c.clear();
}

@@ -109,3 +328,3 @@ function isString(value) {

};
const camelizeRE = /[^A-Za-z0-9]+([A-Za-z0-9])/g;
const camelizeRE = /[^A-Za-z0-9]+([A-Za-z0-9])?/g;
const camelize = cacheStringFunction((str) => {

@@ -128,3 +347,3 @@ return uncapitalize(str.replace(camelizeRE, (_, c) => typeof c === 'string' ? c.toUpperCase() : ''));

function isKebabCase(str) {
return str.includes('-');
return str.includes('-') || /^[a-z0-9]+$/.test(str);
}

@@ -139,4 +358,12 @@ function isPascalCase(str) {

function getComponentName(fileName) {
return pascalCase(Path__namespace.posix.basename(fileName).replace(/\.(vue|ts|tsx|js|jsx)$/, ''));
const name = pascalCase(Path__namespace.posix.basename(fileName).replace(/\.(vue|ts|tsx|js|jsx)$/, ''));
return prefixIfStartsWithNumber(name);
}
function prefixIfStartsWithNumber(name) {
if (/^[0-9]/.test(name)) {
return `_${name}`;
}
else
return name;
}
function getComponentNameAliases(fileNameOrComponentName) {

@@ -147,4 +374,7 @@ const name = Path__namespace.posix

return isKebabCase(name)
? [kebabCase(name)]
: [kebabCase(name), pascalCase(name)];
? [prefixIfStartsWithNumber(kebabCase(name))]
: [
prefixIfStartsWithNumber(kebabCase(name)),
prefixIfStartsWithNumber(pascalCase(name)),
];
}

@@ -156,3 +386,12 @@

function toPosixPath(path) {
return path.includes('\\') ? path.replace(/\\/g, '/') : path;
}
function toWindowsPath(path) {
return path.includes('/') ? path.replace(/\//g, '\\') : path;
}
const toPlatformPath = OS__namespace.platform() === 'win32' ? toWindowsPath : toPosixPath;
function getRelativeFileName(importingFileName, importedFileName) {
importingFileName = toPosixPath(importingFileName);
importedFileName = toPosixPath(importedFileName);
if (Path__namespace.posix.isAbsolute(importingFileName) &&

@@ -185,3 +424,3 @@ Path__namespace.posix.isAbsolute(importedFileName)) {

nodeVersion: process.version,
os: os.platform(),
os: OS.platform(),
...defaults,

@@ -198,2 +437,3 @@ };

}
measure(_name, _duration) { }
trace(name, description) {

@@ -324,8 +564,17 @@ var _a;

exports.Telemetry = Telemetry;
exports.cache = cache;
exports.cacheAll = cacheAll;
exports.cacheAllAsync = cacheAllAsync;
exports.cacheAsync = cacheAsync;
exports.camelCase = camelCase;
exports.camelize = camelize;
exports.capitalize = capitalize;
exports.clearMethodCache = clearMethodCache;
exports.collect = collect;
exports.collectError = collectError;
exports.concat = concat;
exports.createCache = createCache;
exports.createMultiKeyCache = createMultiKeyCache;
exports.createVersionedCache = createVersionedCache;
exports.createWeakMapCache = createWeakMapCache;
exports.findNextSibling = findNextSibling;

@@ -349,5 +598,10 @@ exports.findPrevSibling = findPrevSibling;

exports.pascalCase = pascalCase;
exports.toPlatformPath = toPlatformPath;
exports.toPosixPath = toPosixPath;
exports.toWindowsPath = toWindowsPath;
exports.trace = trace;
exports.tracePromise = tracePromise;
exports.uncapitalize = uncapitalize;
exports.versioned = versioned;
exports.versionedAsync = versionedAsync;
//# sourceMappingURL=index.js.map

2

package.json
{
"name": "@vuedx/shared",
"version": "0.7.4-insiders-1623402835.0",
"version": "0.7.4-insiders-1630600136.0",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "module": "lib/index.mjs",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc