UNPKG

canonical

Version:

Canonical code style linter and formatter for JavaScript, SCSS and CSS.

124 lines (123 loc) 6.61 kB
{ "_args": [ [ "flat-cache@https://registry.npmjs.org/flat-cache/-/flat-cache-1.0.10.tgz", "/Users/gajus/Documents/dev/canonical-code-style/canonical" ] ], "_from": "flat-cache@>=1.0.9 <2.0.0", "_id": "flat-cache@1.0.10", "_inCache": true, "_location": "/flat-cache", "_phantomChildren": {}, "_requested": { "name": "flat-cache", "raw": "flat-cache@https://registry.npmjs.org/flat-cache/-/flat-cache-1.0.10.tgz", "rawSpec": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.0.10.tgz", "scope": null, "spec": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.0.10.tgz", "type": "remote" }, "_requiredBy": [ "/file-entry-cache" ], "_resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.0.10.tgz", "_shasum": "73d6df4a28502160a05e059544a6aeeae8b0047a", "_shrinkwrap": null, "_spec": "flat-cache@https://registry.npmjs.org/flat-cache/-/flat-cache-1.0.10.tgz", "_where": "/Users/gajus/Documents/dev/canonical-code-style/canonical", "author": { "name": "Roy Riojas", "url": "http://royriojas.com" }, "bugs": { "url": "https://github.com/royriojas/flat-cache/issues" }, "changelogx": { "authorURL": "https://github.com/{0}", "commitURL": "https://github.com/royriojas/flat-cache/commit/{0}", "ignoreRegExp": [ "BLD: Release", "DOC: Generate Changelog", "Generated Changelog" ], "issueIDRegExp": "#(\\d+)", "issueIDURL": "https://github.com/royriojas/flat-cache/issues/{0}", "projectName": "flat-cache" }, "dependencies": { "del": "^2.0.2", "graceful-fs": "^4.1.2", "read-json-sync": "^1.1.0", "write": "^0.2.1" }, "description": "A stupidly simple key/value storage using files to persist some data", "devDependencies": { "chai": "^3.2.0", "changelogx": "^1.0.18", "esbeautifier": "^6.1.8", "eslinter": "^3.2.1", "glob-expand": "^0.1.0", "istanbul": "^0.3.19", "mocha": "^2.3.2", "precommit": "^1.1.5", "prepush": "^3.1.4", "proxyquire": "^1.7.2", "sinon": "^1.16.1", "sinon-chai": "^2.8.0", "watch-run": "^1.2.2" }, "engines": { "node": ">=0.10.0" }, "files": [ "cache.js" ], "homepage": "https://github.com/royriojas/flat-cache#readme", "keywords": [ "cache", "file cache", "json cache", "key par", "key value", "simple cache" ], "license": "MIT", "main": "cache.js", "name": "flat-cache", "optionalDependencies": {}, "precommit": [ "npm run verify --silent" ], "prepush": [ "npm run verify --silent" ], "readme": "# flat-cache\n> A stupidly simple key/value storage using files to persist the data\n\n[![NPM Version](http://img.shields.io/npm/v/flat-cache.svg?style=flat)](https://npmjs.org/package/flat-cache)\n[![Build Status](http://img.shields.io/travis/royriojas/flat-cache.svg?style=flat)](https://travis-ci.org/royriojas/flat-cache)\n\n## install\n\n```bash\nnpm i --save flat-cache\n```\n\n## Usage\n\n```js\nvar flatCache = require('flat-cache')\n// loads the cache, if one does not exists for the given\n// Id a new one will be prepared to be created\nvar cache = flatCache.load('cacheId');\n\n// sets a key on the cache\ncache.setKey('key', { foo: 'var' });\n\n// get a key from the cache\ncache.getKey('key') // { foo: 'var' }\n\n// remove a key\ncache.removeKey('key'); // removes a key from the cache\n\n// save it to disk\ncache.save(); // very important, if you don't save no changes will be persisted.\n\n// loads the cache from a given directory, if one does\n// not exists for the given Id a new one will be prepared to be created\nvar cache = flatCache.load('cacheId', path.resolve('./path/to/folder'));\n\n// The following methods are useful to clear the cache\n// delete a given cache\nflatCache.clearCacheById('cacheId') // removes the cacheId document if one exists.\n\n// delete all cache\nflatCache.clearAll(); // remove the cache directory\n```\n\n## Motivation for this module\n\nI needed a super simple and dumb **in-memory cache** with optional disk persistance in order to make\na script that will beutify files with `esformatter` only execute on the files that were changed since the last run.\nTo make that possible we need to store the `fileSize` and `modificationTime` of the files. So a simple `key/value`\nstorage was needed and Bam! this module was born.\n\n## Important notes\n- If no directory is especified when the `load` method is called, a folder named `.cache` will be created\n inside the module directory when `cache.save` is called. If you're committing your `node_modules` to any vcs, you\n might want to ignore the default `.cache` folder, or specify a custom directory.\n- The values set on the keys of the cache should be `stringify-able` ones, meaning no circular references\n- All the changes to the cache state are done to memory\n- I could have used a timer or `Object.observe` to deliver the changes to disk, but I wanted to keep this module\n intentionally dumb and simple\n\n## License\n\nMIT\n\n## Changelog\n\n[changelog](./changelog.md)\n\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/royriojas/flat-cache.git" }, "scripts": { "autofix": "npm run beautify && npm run eslint-fix", "beautify": "esbeautifier 'cache.js' 'specs/**/*.js'", "beautify-check": "npm run beautify -- -k", "bump-major": "npm run pre-v && npm version major -m 'BLD: Release v%s' && npm run post-v", "bump-minor": "npm run pre-v && npm version minor -m 'BLD: Release v%s' && npm run post-v", "bump-patch": "npm run pre-v && npm version patch -m 'BLD: Release v%s' && npm run post-v", "changelog": "changelogx -f markdown -o ./changelog.md", "check": "npm run beautify-check && npm run eslint", "cover": "istanbul cover test/runner.js html text-summary", "do-changelog": "npm run changelog && git add ./changelog.md && git commit -m 'DOC: Generate changelog' --no-verify", "eslint": "eslinter 'cache.js' 'specs/**/*.js'", "eslint-fix": "npm run eslint -- --fix", "install-hooks": "prepush install && changelogx install-hook && precommit install", "post-v": "npm run do-changelog && git push --no-verify && git push --tags --no-verify", "pre-v": "npm run verify", "test": "npm run verify --silent", "test:cache": "mocha -R spec test/specs", "verify": "npm run check && npm run test:cache", "watch": "watch-run -i -p 'test/specs/**/*.js' istanbul cover test/runner.js html text-summary" }, "version": "1.0.10" }