Compare commits

..

No commits in common. "17aee620b3e66f14605d0ab851e7b80ec6553d76" and "326112a16a8cc9966d9df326b3a324c4907e4478" have entirely different histories.

10 changed files with 1 additions and 132 deletions

View file

@ -1,49 +0,0 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cacheMemoria_exports = {};
__export(cacheMemoria_exports, {
cacheM: () => cacheM,
cacheMemoria: () => cacheMemoria,
verCacheM: () => verCacheM
});
module.exports = __toCommonJS(cacheMemoria_exports);
const _cache = {};
const cacheM = (chave, valor, validadeSeg) => {
const txChave = typeof chave == "string" ? chave : typeof chave == "number" ? String(chave) : encodeURIComponent(JSON.stringify(chave));
const validade = validadeSeg && (/* @__PURE__ */ new Date()).getTime() + validadeSeg * 1e3;
if (valor !== void 0) {
_cache[txChave] = {
valor,
validade
};
}
const busca = _cache[txChave];
if (busca?.validade && busca.validade < (/* @__PURE__ */ new Date()).getTime()) {
return void 0;
}
return busca?.valor;
};
const verCacheM = () => _cache;
const cacheMemoria = cacheM;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
cacheM,
cacheMemoria,
verCacheM
});

View file

@ -16,7 +16,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
var index_exports = {}; var index_exports = {};
module.exports = __toCommonJS(index_exports); module.exports = __toCommonJS(index_exports);
__reExport(index_exports, require("./aleatorio"), module.exports); __reExport(index_exports, require("./aleatorio"), module.exports);
__reExport(index_exports, require("./cacheMemoria"), module.exports);
__reExport(index_exports, require("./constantes"), module.exports); __reExport(index_exports, require("./constantes"), module.exports);
__reExport(index_exports, require("./consulta"), module.exports); __reExport(index_exports, require("./consulta"), module.exports);
__reExport(index_exports, require("./ecosistema"), module.exports); __reExport(index_exports, require("./ecosistema"), module.exports);
@ -30,7 +29,6 @@ __reExport(index_exports, require("./variaveisComuns"), module.exports);
// Annotate the CommonJS export names for ESM import in node: // Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = { 0 && (module.exports = {
...require("./aleatorio"), ...require("./aleatorio"),
...require("./cacheMemoria"),
...require("./constantes"), ...require("./constantes"),
...require("./consulta"), ...require("./consulta"),
...require("./ecosistema"), ...require("./ecosistema"),

View file

@ -1,6 +1,3 @@
"use strict"; "use strict";
var import_cacheMemoria = require("./cacheMemoria");
var import_texto_busca = require("./texto_busca"); var import_texto_busca = require("./texto_busca");
console.log("Vari\xE1veis funcionando", import_texto_busca.texto_busca); console.log("Vari\xE1veis funcionando", import_texto_busca.texto_busca);
(0, import_cacheMemoria.cacheM)(1, { Jaca: Promise.resolve() });
console.log("cache:", (0, import_cacheMemoria.cacheM)(1));

View file

@ -1,23 +0,0 @@
const _cache = {};
const cacheM = (chave, valor, validadeSeg) => {
const txChave = typeof chave == "string" ? chave : typeof chave == "number" ? String(chave) : encodeURIComponent(JSON.stringify(chave));
const validade = validadeSeg && (/* @__PURE__ */ new Date()).getTime() + validadeSeg * 1e3;
if (valor !== void 0) {
_cache[txChave] = {
valor,
validade
};
}
const busca = _cache[txChave];
if (busca?.validade && busca.validade < (/* @__PURE__ */ new Date()).getTime()) {
return void 0;
}
return busca?.valor;
};
const verCacheM = () => _cache;
const cacheMemoria = cacheM;
export {
cacheM,
cacheMemoria,
verCacheM
};

View file

@ -1,5 +1,4 @@
export * from "./aleatorio"; export * from "./aleatorio";
export * from "./cacheMemoria";
export * from "./constantes"; export * from "./constantes";
export * from "./consulta"; export * from "./consulta";
export * from "./ecosistema"; export * from "./ecosistema";

View file

@ -1,5 +1,2 @@
import { cacheM } from "./cacheMemoria";
import { texto_busca } from "./texto_busca"; import { texto_busca } from "./texto_busca";
console.log("Vari\xE1veis funcionando", texto_busca); console.log("Vari\xE1veis funcionando", texto_busca);
cacheM(1, { Jaca: Promise.resolve() });
console.log("cache:", cacheM(1));

View file

@ -1,6 +1,6 @@
{ {
"name": "p-comuns", "name": "p-comuns",
"version": "0.158.0", "version": "0.156.0",
"description": "", "description": "",
"main": "./src/index.ts", "main": "./src/index.ts",
"exports": { "exports": {

View file

@ -1,45 +0,0 @@
/** gerar uma função de cache para uso em memoria */
const _cache: {
[k: string]:
| {
/** new Date().getTime() */
validade?: number | undefined
valor: any
}
| undefined
} = {}
export const cacheM = <T>(
chave: any,
valor?: T,
validadeSeg?: number,
): T | undefined => {
// converte a chave e string
const txChave: string =
typeof chave == "string"
? chave
: typeof chave == "number"
? String(chave)
: encodeURIComponent(JSON.stringify(chave))
const validade = validadeSeg && new Date().getTime() + validadeSeg * 1000
if (valor !== undefined) {
_cache[txChave] = {
valor,
validade,
}
}
const busca = _cache[txChave]
if (busca?.validade && busca.validade < new Date().getTime()) {
return undefined
}
return busca?.valor
}
export const verCacheM = () => _cache
export const cacheMemoria = cacheM

View file

@ -1,5 +1,4 @@
export * from "./aleatorio" export * from "./aleatorio"
export * from "./cacheMemoria"
export * from "./constantes" export * from "./constantes"
export * from "./consulta" export * from "./consulta"
export * from "./ecosistema" export * from "./ecosistema"

View file

@ -1,8 +1,4 @@
import { cacheM } from "./cacheMemoria"
import { texto_busca } from "./texto_busca" import { texto_busca } from "./texto_busca"
// node dist-back/teste.mjs // node dist-back/teste.mjs
console.log("Variáveis funcionando", texto_busca) console.log("Variáveis funcionando", texto_busca)
cacheM(1, { Jaca: Promise.resolve() })
console.log("cache:", cacheM(1))