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

knot

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

knot - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

lib/middleware/modules/punycode.js

5

lib/middleware/modules/package.json

@@ -20,5 +20,8 @@ {

"path",
"assert"
"assert",
"url",
"punycode",
"querystring"
]
}
}

61

lib/middleware/node.js

@@ -34,3 +34,4 @@ // (The MIT License)

path = require('path'),
parse = require('url').parse;
parse = require('url').parse,
minify = require("uglify-js");

@@ -44,2 +45,8 @@ /*

/*
* Cache
*/
var cache = {};
/**

@@ -71,2 +78,4 @@ * decodeURIComponent.

* @api private
*
* options.minify = true | false
*/

@@ -81,3 +90,8 @@

path,
file;
file,
start, // Var for wrapping the raw file
middle, // Var to hold the raw file
end, // Var for wrapping the raw file
rawjs, // Var for the minify process
ast; // Var for the minify process

@@ -114,12 +128,47 @@ options = options || {};

if (file.name !== 'process') {
res.write("process('" + file.name + "', function(exports, require, module, __filename, __dirname) {\n");
if (options.cache && cache[file.path]) {
res.end(cache[file.path]);
// console.log('cache hit: ' + file.path);
return;
}
res.write(fs.readFileSync(file.path));
/*
* Generate the start and end JS for the module
*/
start = "process('" + file.name + "', function(exports, require, module, __filename, __dirname) {\n";
middle = fs.readFileSync(file.path, 'utf8');
end = "\n}, {uri: '" + file.uri + "'});";
/*
* If the request is for the the "process" do not wrap it.
*/
if (file.name !== 'process') {
res.write("\n}, {uri: '" + file.uri + "'});");
rawjs = start + middle + end;
} else {
rawjs = middle;
}
/*
* If the minify option is set to true apply it here.
*/
if (options.minify) {
ast = minify.parser.parse(rawjs); // parse code and get the initial AST
ast = minify.uglify.ast_mangle(ast); // get a new AST with mangled names
ast = minify.uglify.ast_squeeze(ast); // get an AST with compression optimizations
rawjs = minify.uglify.gen_code(ast); // compressed code here
}
/*
* If the cache option is set store the rawjs here.
*/
if (options.cache) {
cache[file.path] = rawjs;
}
res.write(rawjs);
res.end();

@@ -126,0 +175,0 @@ }

{
"name": "knot",
"description": "A client side Node experiment.",
"version": "0.0.5",
"version": "0.0.6",
"author": {

@@ -14,3 +14,4 @@ "name": "Richard S Allinson",

"dependencies": {
"connect": "1.x"
"connect": "1.x",
"uglify-js": "1.3.x"
},

@@ -17,0 +18,0 @@ "repository": {

@@ -98,8 +98,17 @@ # Knot Node

Note: Requires "Query Strings".
Note: Not fully tested yet. Requires "Query Strings".
* url.parse(urlStr, [parseQueryString], [slashesDenoteHost])
* url.format(urlObj)
* url.resolve(from, to)
### Query Strings
Notes: process.binding('http_parser').urlDecode. Requires "Buffer".
Note: Not fully tested yet. Commented out "process.binding('http_parser').urlDecode" to make it work.
* querystring.stringify(obj, [sep], [eq])
* querystring.parse(str, [sep], [eq])
* querystring.escape
* querystring.unescape
### Assertion Testing

@@ -106,0 +115,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