--- /dev/null
+var fs = require('fs')
+var util = require('util')
+
+var statAsync = util.promisify(fs.stat)
+
+var BuildCache = function() {
+ if (!this instanceof BuildCache)
+ throw Error('BuildCache is a constructor')
+ this.map = new Map()
+}
+
+BuildCache.prototype.get = async function(key) {
+ var result = this.map.get(key)
+ if (result === undefined)
+ return undefined
+ var deps = result.deps
+ var time = result.time
+ for (var i = 0; i < deps.length; ++i) {
+ stats = await statAsync(deps[i])
+ if (stats.mtimeMs > time) {
+ this.map.delete(key)
+ return undefined
+ }
+ }
+ return result.value
+}
+
+BuildCache.prototype.set = function(key, value, deps) {
+ this.map.set(
+ key,
+ {
+ value: value,
+ deps: deps === undefined ? [key] : deps,
+ time: Date.now()
+ }
+ )
+}
+
+module.exports = BuildCache
--- /dev/null
+{
+ "name": "build_cache",
+ "version": "1.0.0",
+ "description": "Simple caching scheme that checks for modified sources",
+ "main": "build_cache.js",
+ "directories": {},
+ "dependencies": {
+ "fs": "^0.0.1-security"
+ },
+ "devDependencies": {},
+ "scripts": {},
+ "author": "Nick Downing",
+ "license": "GPL-3.0"
+}