Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

minitask

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minitask - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

16

docs/cache.md

@@ -12,2 +12,4 @@ # Cache v2 design

### `Cache.instance()`
The cache is file-oriented. The basic assumption is that if the underlying file changes, then all the results and metadata are invalidated.

@@ -17,4 +19,6 @@

`.get` ensures that each particular location/method combo resolves to just one Cache instance.
### `instance.file()`
`.file` ensures that each particular location/method combo resolves to just one Cache instance.
The second level of the cache is always a file. Ideally, a task contains all the parameters that were used to generate any results associated with it.

@@ -26,2 +30,4 @@

### `instance.file().data()`
Each file can have metadata associated with it:

@@ -33,2 +39,4 @@

### `instance.file().path()`
Each file can also have file paths associated with it:

@@ -40,2 +48,8 @@

### `instance.file().sig()`
`.sig()` returns the cache signature for the file. For `stat`, this is the file size and date modified concatenated into a string. For `md5` and other methods, this is the actual full hash.
### `instance.data()`
For generic metadata shared across all entries in a particular cache location, you can use:

@@ -42,0 +56,0 @@

28

lib/cache-file.js

@@ -99,9 +99,14 @@ var fs = require('fs'),

stat;
if(useCache) {
if(!cache.fsStatCache[this.opts.path]) {
cache.fsStatCache[this.opts.path] = fs.statSync(this.opts.path);
try {
if(useCache) {
if(!cache.fsStatCache[this.opts.path]) {
cache.fsStatCache[this.opts.path] = fs.statSync(this.opts.path);
}
stat = cache.fsStatCache[this.opts.path];
} else {
stat = fs.statSync(this.opts.path);
}
stat = cache.fsStatCache[this.opts.path];
} else {
stat = fs.statSync(this.opts.path);
} catch (e) {
// file may not exist
return { size: 0, mtime: 0 };
}

@@ -114,2 +119,13 @@ return { size: stat.size, mtime: parseInt(stat.mtime.getTime(), 10) };

CacheFile.prototype.sig = function() {
var actual = this._getActual(),
hash;
if (this.opts.method != 'stat') {
return actual;
}
hash = (actual.mtime instanceof Date ? actual.mtime : new Date(actual.mtime)).getTime() +
'-' + actual.size;
return hash;
};
CacheFile.prototype._compare = function(actual, expected) {

@@ -116,0 +132,0 @@ return (this.opts.method == 'stat' ? !statEqual(actual, expected) : (expected != actual));

{
"name": "minitask",
"version": "0.2.2",
"version": "0.2.3",
"description": "A standard/convention for running tasks over a list of files based around Node core streams2",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc