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

express-istatic

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-istatic - npm Package Compare versions

Comparing version 0.0.9 to 0.1.0

17

lib/istatic.js

@@ -44,2 +44,4 @@ var uglify = require('./uglify.js');

opts = opts || options || defaultOptions;
var str = read(path, opts) || '';

@@ -49,3 +51,3 @@

if (str.indexOf('#{') > -1) {
compiled_fns[path] = function(locals) {
var fn = function(locals) {
return str.replace(reg_val, function(m0, m1) {

@@ -56,3 +58,14 @@ var fn = new Function('locals', 'with (locals) { return ' + m1 + '; }');

};
return compiled_fns[path](this);
var ttl = opts && opts.ttl || 0;
if (!ttl && ttl !== 0 || ttl > 5) {
compiled_fns[path] = fn;
}
if (ttl > 5) {
setTimeout(function() {
delete compiled_fns[path];
}, ttl * 1000);
}
return fn(this);
}

@@ -59,0 +72,0 @@

19

lib/read.js

@@ -6,9 +6,9 @@ var fs = require('fs');

var stylus = require('stylus');
var debug = require('debug')('istatic');
var log = require('debug')('istatic');
function waitStale(ttl, _t) {
function globalStale(ttl, _t) {
try {
clearInterval(_t);
} catch (e) {}
_t = setInterval(function() { cache = {}; }, ttl * 1000);
_t = setInterval(function() { global_cache = {}; }, ttl * 1000);
}

@@ -41,3 +41,4 @@

if (ttl > 5) {
waitStale(ttl, _t);
globalStale(ttl, _t);
setInterval(function() { cache = {}; }, ttl * 1000);
} else {

@@ -67,3 +68,3 @@ // if the ttl is less than 5 seconds,

var charset = opt.charset || 'utf-8';
var debug = process.env.DEBUG || opt.debug;
var debug = 'debug' in opt ? opt.debug : process.env.DEBUG;
var doCompress = 'compress' in opt ? opt.compress : true;

@@ -79,3 +80,5 @@ var _doCache = opt.fresh ? false : doCache;

} catch (e) {
debug('Reading..', filepath, e);
log('Reading %s failed: %s', filepath, e);
if (opt.debug) throw e;
return '/* == istatic: no such file: ' + filepath + ' == */';
}

@@ -87,3 +90,3 @@

stylus.render(str, function(err, str) {
if (err) debug('Compiling', filepath, err);
if (err) log('Compiling %s failed: %s', filepath, err);
else cache[filepath] = _uglify('css', str, opt.css, doCompress);

@@ -94,3 +97,3 @@ });

less.render(str, function(err, str) {
if (err) debug('Compiling', filepath, err);
if (err) log('Compiling %s failed: %s', filepath, err);
else cache[filepath] = _uglify('css', str, opt.css, doCompress);

@@ -97,0 +100,0 @@ });

@@ -1,16 +0,11 @@

var uglifycss = require('uglifycss');
var cleancss = require('clean-css');
var uglifyjs = require('uglify-js');
var jsp = uglifyjs.parser;
var pro = uglifyjs.uglify;
module.exports = {
js: function(str, opt) {
var ast = jsp.parse(str);
ast = pro.ast_mangle(ast);
ast = pro.ast_squeeze(ast);
return pro.gen_code(ast, opt);
js: function(code) {
return uglifyjs.minify(code, { fromString: true, }).code;
},
css: function(str, opt) {
return uglifycss.processString(str, opt);
css: function(code) {
return cleancss.process(code);
}
};
{
"name": "express-istatic",
"version": "0.0.9",
"version": "0.1.0",
"homepage": "http://github.com/ktmud/express-istatic",

@@ -11,7 +11,7 @@ "description": "Add compressed inline css and scripts to your html, but write them as seperated files.",

"dependencies": {
"less": ">= 1.0",
"debug": "*",
"stylus": ">= 0.1",
"uglify-js": "1.3.x",
"uglifycss": ">= 0.0.5"
"less": "~1.3.1",
"debug": "~0.7.2",
"stylus": "~0.32.1",
"uglify-js": "~2.2.5",
"clean-css": "~1.0.1"
},

@@ -18,0 +18,0 @@ "engines": {

@@ -103,4 +103,6 @@ # Inline Static Files for express / connect / nodejs

`filename` is the path of your static file. If it begins with a '/', the real path will be `process.cwd() + filename`. Otherwise, the file will be looked up from the root of your inline static files, as you configured before.
`filename` is the path of your static file.
If it begins with a `'/'`, the real path will be `process.cwd() + filename`. Otherwise, the file will be looked up from the root of your inline static files, as you configured before.
You can set available options above, except for `root` and `ttl`. A `fresh` option is available for you to set this `istatic` call always read from file directly.

@@ -107,0 +109,0 @@

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