New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

istatic

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

istatic - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7-1

10

lib/istatic.js

@@ -37,6 +37,8 @@ var uglify = require('./uglify.js');

var exports = function(path, forceReload, options) {
if (options) defaultOptions = options;
if (!defaultRead) defaultRead = theRead(defaultOptions);
return defaultRead(path, forceReload);
var exports = function(path, options) {
if (!defaultRead) {
if (options) defaultOptions = options;
defaultRead = theRead(defaultOptions);
}
return defaultRead(path, options);
};

@@ -43,0 +45,0 @@

36

lib/read.js

@@ -65,33 +65,39 @@ var fs = require('fs');

var charset = opt.charset || 'utf-8';
var debug = process.env.DEBUG || opt.debug;
var doCompress = 'compress' in opt ? opt.compress : true;
var doCache = opt.fresh ? false : doCache;
var _doCache = opt.fresh ? false : doCache;
var str = doCache ? (cache[filepath] || global_cache[filepath]) : '';
var str = _doCache ? (cache[filepath] || global_cache[filepath]) : '';
if (str && doCache) return str;
if (str && _doCache) return str;
str = fs.readFileSync(filepath, charset);
try {
str = fs.readFileSync(filepath, charset);
} catch (e) {
console.error('[istatic] Reading..', filepath, e);
}
switch (filetype) {
case 'js':
str = _uglify('js', str, opt.js, doCompress);
break;
case 'styl':
filetype = 'css';
stylus.render(str, function(err, str) {
if (!err) cache[filepath] = _uglify('css', str, opt.css, doCompress);
if (err) console.error('[istatic] Compiling', filepath, err);
else cache[filepath] = _uglify('css', str, opt.css, doCompress);
});
case 'less':
filetype = 'css';
less.render(str, function(err, str) {
if (!err) cache[filepath] = _uglify('css', str, opt.css, doCompress);
if (err) console.error('[istatic] Compiling', filepath, err);
else cache[filepath] = _uglify('css', str, opt.css, doCompress);
});
// better simple than none
// once the render is done, we can safely return good css
break;
case 'css':
str = _uglify('css', str, opt.css, doCompress);
//case 'js':
//case 'css':
default:
// return the original str
if (filetype == 'css' || filetype == 'js')
str = _uglify(filetype, str, opt[filetype], doCompress);
}
if (opt.showPath) str = '\n/* == istatic: ' + filepath + ' == */\n' + str;
if (doCache) cache[filepath] = global_cache[filepath] = str;
if (debug) str = '\n/* == istatic: ' + filepath + ' == */\n' + str;
if (_doCache) cache[filepath] = global_cache[filepath] = str;
return str;

@@ -98,0 +104,0 @@ };

{
"name": "istatic",
"version": "0.0.6",
"version": "0.0.7-1",
"homepage": "http://github.com/ktmud/express-istatic",

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

@@ -112,3 +112,3 @@ # Inline Static Files for express / connect / nodejs

Set default options for `istatic.enable` and `istatic.inline`. This can be implictly done by call `istatic(filename, [forceReload, options])` and pass the `options` object.
Specificly set default options for `istatic('filepath')`, which will be set implicitly at the first call of `istatic('filename', options)`.

@@ -123,2 +123,7 @@ ### istatic.uglify.css(str, [options])

## Outside template usage:
var istatic = require('istatic');
var some_js_str = istatic('/util/something.js', { compress: true });
## Example

@@ -125,0 +130,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