Current Dev State

This commit is contained in:
Tim Lorsbach
2025-06-23 20:13:54 +02:00
parent b4f9bb277d
commit ded50edaa2
22617 changed files with 4345095 additions and 174 deletions

View File

@ -0,0 +1,3 @@
# fs-exists-cached
Just like `fs.exists` and `fs.existsSync`, but cached

View File

@ -0,0 +1,24 @@
module.exports = exists
exists.sync = sync
var fs = require('fs')
var existsCache = Object.create(null)
function exists (file, cb) {
if (file in existsCache)
return process.nextTick(cb.bind(null, existsCache[file]))
fs.lstat(file, function (er) {
cb(existsCache[file] = !er)
})
}
function sync (file) {
if (file in existsCache)
return existsCache[file]
try {
fs.lstatSync(file)
existsCache[file] = true
} catch (er) {
existsCache[file] = false
}
return existsCache[file]
}

View File

@ -0,0 +1,53 @@
{
"_from": "fs-exists-cached@^1.0.0",
"_id": "fs-exists-cached@1.0.0",
"_inBundle": false,
"_integrity": "sha1-zyVVTKBQ3EmuZla0HeQiWJidy84=",
"_location": "/fs-exists-cached",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "fs-exists-cached@^1.0.0",
"name": "fs-exists-cached",
"escapedName": "fs-exists-cached",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/tap"
],
"_resolved": "https://registry.npmjs.org/fs-exists-cached/-/fs-exists-cached-1.0.0.tgz",
"_shasum": "cf25554ca050dc49ae6656b41de42258989dcbce",
"_spec": "fs-exists-cached@^1.0.0",
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/tap",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"bugs": {
"url": "https://github.com/isaacs/fs-exists-cached/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "Just like `fs.exists` and `fs.existsSync`, but cached",
"devDependencies": {
"tap": "9 || 10"
},
"homepage": "https://github.com/isaacs/fs-exists-cached#readme",
"keywords": [],
"license": "ISC",
"main": "index.js",
"name": "fs-exists-cached",
"repository": {
"type": "git",
"url": "git+https://github.com/isaacs/fs-exists-cached.git"
},
"scripts": {
"test": "tap test.js --100"
},
"version": "1.0.0"
}

View File

@ -0,0 +1,60 @@
var exists = require('./')
var t = require('tap')
var touch = require('touch')
var rimraf = require('rimraf')
t.test('setup', function (t) {
touch.sync('one')
touch.sync('two')
touch.sync('three')
touch.sync('four')
t.end()
})
t.test('existing file same way', function (t) {
t.plan(4)
t.ok(exists.sync('one'))
t.ok(exists.sync('one'))
exists('two', function (e) {
t.ok(e)
exists('two', t.ok)
})
})
t.test('existing file different ways', function (t) {
t.plan(4)
t.ok(exists.sync('three'))
t.ok(exists.sync('four'))
exists('three', function (e) {
t.ok(e)
exists('four', t.ok)
})
})
t.test('non-existing file same way', function (t) {
t.plan(4)
t.notOk(exists.sync('one-no'))
t.notOk(exists.sync('one-no'))
exists('two-no', function (e) {
t.notOk(e)
exists('two-no', t.notOk)
})
})
t.test('non-existing file different ways', function (t) {
t.plan(4)
t.notOk(exists.sync('three-no'))
t.notOk(exists.sync('four-no'))
exists('three-no', function (e) {
t.notOk(e)
exists('four-no', t.notOk)
})
})
t.test('cleanup', function (t) {
rimraf.sync('one')
rimraf.sync('two')
rimraf.sync('three')
rimraf.sync('four')
t.end()
})