[Pkg-javascript-commits] [node-roadrunner] 01/03: Import Upstream version 1.1.0
Paolo Greppi
paolog-guest at moszumanska.debian.org
Mon Dec 12 10:06:19 UTC 2016
This is an automated email from the git hooks/post-receive script.
paolog-guest pushed a commit to branch master
in repository node-roadrunner.
commit 737201f37f5c8dfc028e1f9eab7d6fc88f30a79c
Author: Paolo Greppi <paolo.greppi at libpf.com>
Date: Mon Dec 12 09:59:21 2016 +0000
Import Upstream version 1.1.0
---
.jshintrc | 3 +++
LICENSE | 22 ++++++++++++++++++++
README.md | 20 +++++++++++++++++++
index.js | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package.json | 9 +++++++++
5 files changed, 119 insertions(+)
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..c1f2978
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "node": true
+}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..99ffaf8
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2014 Sebastian McKenzie
+
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..70d038d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,20 @@
+# roadrunner
+
+Roadrunner will cache require resolutions to heavily improve startup speed of
+your node application.
+
+## Installation
+
+ $ npm install roadrunner
+
+## Usage
+
+```javascript
+var roadrunner = require("roadrunner");
+
+roadrunner.load();
+
+// your code here
+
+roadrunner.save();
+```
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..217e7ed
--- /dev/null
+++ b/index.js
@@ -0,0 +1,65 @@
+"use strict";
+
+var Module = require("module");
+var fs = require("fs");
+
+var FILENAME = ".roadrunner.json";
+var data = {};
+
+var wrap = function (fn) {
+ return function (filename) {
+ filename = filename || FILENAME;
+ return fn(filename);
+ };
+};
+
+var init = function () {
+ Module._pathCache = exports.get("path");
+ Module._realpathCache = exports.get("realpath");
+};
+
+exports.save = wrap(function (filename) {
+ exports.set("realpath", Module._realpathCache);
+ exports.set("path", Module._pathCache);
+
+ fs.writeFileSync(filename, JSON.stringify(data, null, " "));
+});
+
+exports.load = wrap(function (filename) {
+ if (!fs.existsSync(filename)) return;
+
+ try {
+ data = JSON.parse(fs.readFileSync(filename));
+ } catch (err) {
+ return;
+ }
+
+ init();
+});
+
+exports.setup = wrap(function (filename) {
+ var save = exports.save.bind(null, filename);
+ process.on("exit", save);
+
+ process.on("SIGINT", function sigint() {
+ process.removeListener("SIGINT", sigint);
+ save();
+ process.kill(process.pid, "SIGINT");
+ });
+});
+
+exports.reset = wrap(function (filename) {
+ if (fs.existsSync(filename)) fs.unlinkSync(filename);
+
+ data = {};
+
+ init();
+});
+
+exports.get = function (key) {
+ return data[key] = data[key] || {};
+};
+
+exports.set = function (key, val) {
+ return data[key] = val;
+};
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..498a302
--- /dev/null
+++ b/package.json
@@ -0,0 +1,9 @@
+{
+ "name": "roadrunner",
+ "version": "1.1.0",
+ "description": "Cache require resolutions to heavily improve startup speed on subsequent loads",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/sebmck/roadrunner.git"
+ }
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-roadrunner.git
More information about the Pkg-javascript-commits
mailing list