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

@xinferai/utils-lib

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xinferai/utils-lib - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

10

dist/browser/index.d.ts

@@ -249,2 +249,9 @@ /**

/**
* getUUID - Get a UUID from the cache or generate a new one
*
* @returns {string} - A UUID
*/
declare const getUUID: () => string;
declare const _default: {

@@ -281,4 +288,5 @@ base64ToBinary: typeof base64ToBinary;

utf8ToBase64: typeof utf8ToBase64;
getUUID: () => string;
};
export { type AudioPcmParams, type GetWaveBufferOptions, type PlainObject, type PlainValue, base64ToBinary, base64ToString, camelToSnake, decryptString, deepClone, deepEqual, _default as default, encryptString, endsWithAtToDate, extractError, getJsString, getPassphrase, getPcmHeader, getVoiceFrames, getWaveBuffer, isBase64, isInBrowser, isInNode, isPcm16, isPlainObject, isPlainValue, isTextFile, parseDate, passThrough, pluralize, readRaw, sentenceCase, setPassphrase, snakeToCamel, toHumanReadable, utf8ToBase64 };
export { type AudioPcmParams, type GetWaveBufferOptions, type PlainObject, type PlainValue, base64ToBinary, base64ToString, camelToSnake, decryptString, deepClone, deepEqual, _default as default, encryptString, endsWithAtToDate, extractError, getJsString, getPassphrase, getPcmHeader, getUUID, getVoiceFrames, getWaveBuffer, isBase64, isInBrowser, isInNode, isPcm16, isPlainObject, isPlainValue, isTextFile, parseDate, passThrough, pluralize, readRaw, sentenceCase, setPassphrase, snakeToCamel, toHumanReadable, utf8ToBase64 };

@@ -36,2 +36,3 @@ "use strict";

getPcmHeader: () => getPcmHeader,
getUUID: () => getUUID,
getVoiceFrames: () => getVoiceFrames,

@@ -918,2 +919,94 @@ getWaveBuffer: () => getWaveBuffer,

// node_modules/uuid/dist/esm/stringify.js
var byteToHex = [];
for (let i = 0; i < 256; ++i) {
byteToHex.push((i + 256).toString(16).slice(1));
}
function unsafeStringify(arr, offset = 0) {
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
}
// node_modules/uuid/dist/esm/rng.js
var import_crypto = require("crypto");
var rnds8Pool = new Uint8Array(256);
var poolPtr = rnds8Pool.length;
function rng() {
if (poolPtr > rnds8Pool.length - 16) {
(0, import_crypto.randomFillSync)(rnds8Pool);
poolPtr = 0;
}
return rnds8Pool.slice(poolPtr, poolPtr += 16);
}
// node_modules/uuid/dist/esm/native.js
var import_crypto2 = require("crypto");
var native_default = { randomUUID: import_crypto2.randomUUID };
// node_modules/uuid/dist/esm/v4.js
function v4(options, buf, offset) {
if (native_default.randomUUID && !buf && !options) {
return native_default.randomUUID();
}
options = options || {};
const rnds = options.random || (options.rng || rng)();
rnds[6] = rnds[6] & 15 | 64;
rnds[8] = rnds[8] & 63 | 128;
if (buf) {
offset = offset || 0;
for (let i = 0; i < 16; ++i) {
buf[offset + i] = rnds[i];
}
return buf;
}
return unsafeStringify(rnds);
}
var v4_default = v4;
// src/get-uuid.ts
var UUIDCache = class {
/**
* @param {number} cacheSize - The maximum number of UUIDs to cache
* @param {number} lowWaterMark - The minimum number of UUIDs to keep in the cache
*/
constructor(cacheSize = 1e3, lowWaterMark = Math.floor(cacheSize * 0.2)) {
this.cacheSize = cacheSize;
this.lowWaterMark = lowWaterMark;
this.cache = [];
this.isGenerating = false;
this.fillCache();
}
getUUID() {
if (this.cache.length <= this.lowWaterMark) {
this.fillCache();
}
return this.cache.pop() || v4_default();
}
// For testing/monitoring
getCacheSize() {
return this.cache.length;
}
fillCache() {
if (this.isGenerating) return;
this.isGenerating = true;
const generateBatch = () => {
const batchSize = 100;
let generated = 0;
while (generated < batchSize && this.cache.length < this.cacheSize) {
this.cache.push(v4_default());
generated++;
}
if (this.cache.length < this.cacheSize) {
setImmediate(generateBatch);
} else {
this.isGenerating = false;
}
};
setImmediate(generateBatch);
}
};
var uuidCache = new UUIDCache();
var getUUID = () => {
return uuidCache.getUUID();
};
// src/index-browser.ts

@@ -952,3 +1045,4 @@ var index_browser_default = {

toHumanReadable,
utf8ToBase64
utf8ToBase64,
getUUID
};

@@ -969,2 +1063,3 @@ // Annotate the CommonJS export names for ESM import in node:

getPcmHeader,
getUUID,
getVoiceFrames,

@@ -971,0 +1066,0 @@ getWaveBuffer,

@@ -267,2 +267,9 @@ interface AudioPcmParams {

/**
* getUUID - Get a UUID from the cache or generate a new one
*
* @returns {string} - A UUID
*/
declare const getUUID: () => string;
declare const _default: {

@@ -301,4 +308,5 @@ appendWavFile: typeof appendWavFile;

utf8ToBase64: typeof utf8ToBase64;
getUUID: () => string;
};
export { type AudioPcmParams, type GetWaveBufferOptions, type PlainObject, type PlainValue, appendWavFile, base64ToBinary, base64ToString, camelToSnake, decryptString, deepClone, deepEqual, _default as default, encryptString, endsWithAtToDate, extractError, fileToBase64, getJsString, getPassphrase, getPcmHeader, getVoiceFrames, getWaveBuffer, isBase64, isInBrowser, isInNode, isPcm16, isPlainObject, isPlainValue, isTextFile, parseDate, passThrough, pluralize, readRaw, sentenceCase, setPassphrase, snakeToCamel, toHumanReadable, utf8ToBase64 };
export { type AudioPcmParams, type GetWaveBufferOptions, type PlainObject, type PlainValue, appendWavFile, base64ToBinary, base64ToString, camelToSnake, decryptString, deepClone, deepEqual, _default as default, encryptString, endsWithAtToDate, extractError, fileToBase64, getJsString, getPassphrase, getPcmHeader, getUUID, getVoiceFrames, getWaveBuffer, isBase64, isInBrowser, isInNode, isPcm16, isPlainObject, isPlainValue, isTextFile, parseDate, passThrough, pluralize, readRaw, sentenceCase, setPassphrase, snakeToCamel, toHumanReadable, utf8ToBase64 };

@@ -48,2 +48,3 @@ "use strict";

getPcmHeader: () => getPcmHeader,
getUUID: () => getUUID,
getVoiceFrames: () => getVoiceFrames,

@@ -949,2 +950,94 @@ getWaveBuffer: () => getWaveBuffer,

// node_modules/uuid/dist/esm/stringify.js
var byteToHex = [];
for (let i = 0; i < 256; ++i) {
byteToHex.push((i + 256).toString(16).slice(1));
}
function unsafeStringify(arr, offset = 0) {
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
}
// node_modules/uuid/dist/esm/rng.js
var import_crypto2 = require("crypto");
var rnds8Pool = new Uint8Array(256);
var poolPtr = rnds8Pool.length;
function rng() {
if (poolPtr > rnds8Pool.length - 16) {
(0, import_crypto2.randomFillSync)(rnds8Pool);
poolPtr = 0;
}
return rnds8Pool.slice(poolPtr, poolPtr += 16);
}
// node_modules/uuid/dist/esm/native.js
var import_crypto3 = require("crypto");
var native_default = { randomUUID: import_crypto3.randomUUID };
// node_modules/uuid/dist/esm/v4.js
function v4(options, buf, offset) {
if (native_default.randomUUID && !buf && !options) {
return native_default.randomUUID();
}
options = options || {};
const rnds = options.random || (options.rng || rng)();
rnds[6] = rnds[6] & 15 | 64;
rnds[8] = rnds[8] & 63 | 128;
if (buf) {
offset = offset || 0;
for (let i = 0; i < 16; ++i) {
buf[offset + i] = rnds[i];
}
return buf;
}
return unsafeStringify(rnds);
}
var v4_default = v4;
// src/get-uuid.ts
var UUIDCache = class {
/**
* @param {number} cacheSize - The maximum number of UUIDs to cache
* @param {number} lowWaterMark - The minimum number of UUIDs to keep in the cache
*/
constructor(cacheSize = 1e3, lowWaterMark = Math.floor(cacheSize * 0.2)) {
this.cacheSize = cacheSize;
this.lowWaterMark = lowWaterMark;
this.cache = [];
this.isGenerating = false;
this.fillCache();
}
getUUID() {
if (this.cache.length <= this.lowWaterMark) {
this.fillCache();
}
return this.cache.pop() || v4_default();
}
// For testing/monitoring
getCacheSize() {
return this.cache.length;
}
fillCache() {
if (this.isGenerating) return;
this.isGenerating = true;
const generateBatch = () => {
const batchSize = 100;
let generated = 0;
while (generated < batchSize && this.cache.length < this.cacheSize) {
this.cache.push(v4_default());
generated++;
}
if (this.cache.length < this.cacheSize) {
setImmediate(generateBatch);
} else {
this.isGenerating = false;
}
};
setImmediate(generateBatch);
}
};
var uuidCache = new UUIDCache();
var getUUID = () => {
return uuidCache.getUUID();
};
// src/index-node.ts

@@ -983,3 +1076,4 @@ var index_node_default = {

toHumanReadable,
utf8ToBase64
utf8ToBase64,
getUUID
};

@@ -1002,2 +1096,3 @@ // Annotate the CommonJS export names for ESM import in node:

getPcmHeader,
getUUID,
getVoiceFrames,

@@ -1004,0 +1099,0 @@ getWaveBuffer,

5

package.json
{
"name": "@xinferai/utils-lib",
"version": "1.0.4",
"version": "1.0.5",
"exports": {

@@ -56,4 +56,5 @@ ".": {

"tsup": "^8.3.0",
"typescript": "^5.6.2"
"typescript": "^5.6.2",
"uuid": "^11.0.3"
}
}

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

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