This commit is contained in:
NoryiE
2025-02-16 14:12:49 +00:00
parent c6a89e5b35
commit e0aeb9b06e
2737 changed files with 5220 additions and 1039045 deletions

View File

@@ -1,37 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function createInMemoryCache(options = { serializable: true }) {
// eslint-disable-next-line functional/no-let
let cache = {};
return {
get(key, defaultValue, events = {
miss: () => Promise.resolve(),
}) {
const keyAsString = JSON.stringify(key);
if (keyAsString in cache) {
return Promise.resolve(options.serializable ? JSON.parse(cache[keyAsString]) : cache[keyAsString]);
}
const promise = defaultValue();
const miss = (events && events.miss) || (() => Promise.resolve());
return promise.then((value) => miss(value)).then(() => promise);
},
set(key, value) {
// eslint-disable-next-line functional/immutable-data
cache[JSON.stringify(key)] = options.serializable ? JSON.stringify(value) : value;
return Promise.resolve(value);
},
delete(key) {
// eslint-disable-next-line functional/immutable-data
delete cache[JSON.stringify(key)];
return Promise.resolve();
},
clear() {
cache = {};
return Promise.resolve();
},
};
}
exports.createInMemoryCache = createInMemoryCache;

View File

@@ -1,12 +0,0 @@
import { Cache } from '@algolia/cache-common';
export declare function createInMemoryCache(options?: InMemoryCacheOptions): Cache;
export declare type InMemoryCacheOptions = {
/**
* If keys and values should be serialized using `JSON.stringify`.
*/
readonly serializable?: boolean;
};
export { }

View File

@@ -1,33 +0,0 @@
function createInMemoryCache(options = { serializable: true }) {
// eslint-disable-next-line functional/no-let
let cache = {};
return {
get(key, defaultValue, events = {
miss: () => Promise.resolve(),
}) {
const keyAsString = JSON.stringify(key);
if (keyAsString in cache) {
return Promise.resolve(options.serializable ? JSON.parse(cache[keyAsString]) : cache[keyAsString]);
}
const promise = defaultValue();
const miss = (events && events.miss) || (() => Promise.resolve());
return promise.then((value) => miss(value)).then(() => promise);
},
set(key, value) {
// eslint-disable-next-line functional/immutable-data
cache[JSON.stringify(key)] = options.serializable ? JSON.stringify(value) : value;
return Promise.resolve(value);
},
delete(key) {
// eslint-disable-next-line functional/immutable-data
delete cache[JSON.stringify(key)];
return Promise.resolve();
},
clear() {
cache = {};
return Promise.resolve();
},
};
}
export { createInMemoryCache };

View File

@@ -1,2 +0,0 @@
// eslint-disable-next-line functional/immutable-data, import/no-commonjs
module.exports = require('./dist/cache-in-memory.cjs.js');

View File

@@ -1,22 +0,0 @@
{
"name": "@algolia/cache-in-memory",
"version": "4.20.0",
"private": false,
"description": "Promise-based cache library using memory.",
"repository": {
"type": "git",
"url": "git://github.com/algolia/algoliasearch-client-javascript.git"
},
"license": "MIT",
"sideEffects": false,
"main": "index.js",
"module": "dist/cache-in-memory.esm.js",
"types": "dist/cache-in-memory.d.ts",
"files": [
"index.js",
"dist"
],
"dependencies": {
"@algolia/cache-common": "4.20.0"
}
}