@helios-lang/contract-utils
Advanced tools
Comparing version 0.2.75 to 0.2.76
{ | ||
"name": "@helios-lang/contract-utils", | ||
"version": "0.2.75", | ||
"version": "0.2.76", | ||
"description": "Convenience and type-safety utilities for using Helios validators from within Typescript", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -0,1 +1,4 @@ | ||
import * as fs from "node:fs" | ||
import * as os from "node:os" | ||
import * as path from "node:path" | ||
import { contractContextCache } from "./ContractContextCache.js" | ||
@@ -14,20 +17,2 @@ | ||
* @private | ||
* @type {typeof import("node:fs")} | ||
*/ | ||
fs | ||
/** | ||
* @private | ||
* @type {typeof import("node:os")} | ||
*/ | ||
os | ||
/** | ||
* @private | ||
* @type {typeof import("node:path")} | ||
*/ | ||
path | ||
/** | ||
* @private | ||
* @type {string} | ||
@@ -38,19 +23,9 @@ */ | ||
constructor() { | ||
// hopefully this loads before starting the context build | ||
Promise.all([ | ||
import("node:fs"), | ||
import("node:os"), | ||
import("node:path") | ||
]).then(([fs, os, path]) => { | ||
this.fs = fs | ||
this.os = os | ||
this.path = path | ||
this.cacheDir = this.path.join(this.os.tmpdir(), "helios-cache") | ||
this.cacheDir = path.join(os.tmpdir(), "helios-cache") | ||
if (!this.fs.existsSync(this.cacheDir)) { | ||
this.fs.mkdirSync(this.cacheDir, { | ||
recursive: true | ||
}) | ||
} | ||
}) | ||
if (!fs.existsSync(this.cacheDir)) { | ||
fs.mkdirSync(this.cacheDir, { | ||
recursive: true | ||
}) | ||
} | ||
} | ||
@@ -63,3 +38,3 @@ | ||
genPath(key) { | ||
return this.path.join(this.cacheDir, key + ".json") | ||
return path.join(this.cacheDir, key + ".json") | ||
} | ||
@@ -71,3 +46,3 @@ | ||
has(key) { | ||
return this.fs.existsSync(this.genPath(key)) | ||
return fs.existsSync(this.genPath(key)) | ||
} | ||
@@ -80,3 +55,3 @@ | ||
get(key) { | ||
return JSON.parse(this.fs.readFileSync(this.genPath(key)).toString()) | ||
return JSON.parse(fs.readFileSync(this.genPath(key)).toString()) | ||
} | ||
@@ -89,3 +64,3 @@ | ||
set(key, obj) { | ||
this.fs.writeFileSync(this.genPath(key), JSON.stringify(obj)) | ||
fs.writeFileSync(this.genPath(key), JSON.stringify(obj)) | ||
} | ||
@@ -92,0 +67,0 @@ } |
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
258104
6251