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.1 to 0.0.2

license.md

2

examples/simple_example/app.js

@@ -8,3 +8,3 @@

stache = require('stache'),
knot = require('../../'),
knot = require('knot'),
app = express.createServer();

@@ -11,0 +11,0 @@

@@ -15,4 +15,5 @@ {

"express": "2.5.x",
"stache": "0.1.0"
"stache": "0.1.0",
"knot": ">= 0.0.1"
}
}

@@ -0,2 +1,24 @@

// (The MIT License)
//
// Copyright (c) 2012 Richard S Allinson <rsa@mountainmansoftware.com>
//
// 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.
module.exports = require('./lib');

@@ -0,2 +1,24 @@

// (The MIT License)
//
// Copyright (c) 2012 Richard S Allinson <rsa@mountainmansoftware.com>
//
// 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.
exports.node = require('./middleware/node');

@@ -0,4 +1,28 @@

// (The MIT License)
//
// Copyright (c) 2012 Richard S Allinson <rsa@mountainmansoftware.com>
//
// 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.
/*
* The main "process" namespace variable.
*/
var process = (function(){

@@ -8,3 +32,7 @@

* This function eval's module code in the process scope.
*
* @param {string} js
* @api private
*/
function evalModuleInScope(js) {

@@ -17,7 +45,8 @@ eval(js);

* access knot and its inner functions.
*
* @api private
*/
return function(){
// var URL_PREFIX = process.installPrefix;
/*

@@ -53,3 +82,7 @@ * Provide the XMLHttpRequest constructor for Internet Explorer 5.x-6.x:

* ClientModule
*
* @param {string} id
* @api private
*/
function ClientModule(id) {

@@ -62,5 +95,22 @@ this.id = id;

/*
* Function cache.
*/
ClientModule.modules = {};
/*
* Object cache.
*/
ClientModule.cache = {};
/*
* The "require()" function used by all modules.
*
* @param {string} id
* @param {string} parentPath
* @api private
*/
ClientModule.require = function(id, parentPath) {

@@ -89,4 +139,2 @@

// process.moduleLoadList.push('ClientModule ' + id);
clientModule = new ClientModule(id);

@@ -100,2 +148,9 @@

/*
* Returns true if the id is a cached module.
*
* @param {string} id
* @api private
*/
ClientModule.getCached = function(id) {

@@ -131,2 +186,3 @@ return ClientModule.cache[id];

*/
if (!callback) {

@@ -143,2 +199,3 @@ script = new XMLHttpRequest();

*/
script = document.createElement("script");

@@ -165,2 +222,9 @@ script.type = "text/javascript";

/*
* Checks if the given id exists.
*
* @param {string} parentPath
* @api private
*/
ClientModule.exists = function(id) {

@@ -170,2 +234,8 @@ return ClientModule.modules.hasOwnProperty(id);

/*
* Run the function.
*
* @api private
*/
ClientModule.prototype.compile = function() {

@@ -187,2 +257,8 @@

/*
* Add the current module to the cache.
*
* @api private
*/
ClientModule.prototype.cache = function() {

@@ -192,5 +268,12 @@ ClientModule.cache[this.id] = this;

// Wrap a core module's method in a wrapper that will warn on first use
// and then return the result of invoking the original function. After
// first being called the original method is restored.
/*
* Wrap a core module's method in a wrapper that will warn on first use
* and then return the result of invoking the original function. After
* first being called the original method is restored.
*
* @param {string} method
* @param {string} message
* @api private
*/
ClientModule.prototype.deprecate = function(method, message) {

@@ -251,2 +334,10 @@ var original = this.exports[method];

/*
* The plan for meta is to have it contain an array of module
* dependancies so they can be loaded asynchronously before the
* module is executed. To do this the server side of knot will
* need to provide the array as part of the process() functions
* arguments.
*/
if (!meta) {

@@ -261,2 +352,3 @@ meta = {

*/
ClientModule.modules[id] = {

@@ -268,4 +360,5 @@ uri: meta.uri,

/*
* If the module has no name then it should be required.
* If the module has no name then it should be required immediately.
*/
if (id === '') {

@@ -276,2 +369,3 @@ ClientModule.require(id);

}();
})();

@@ -282,2 +376,3 @@

*/
(function(){

@@ -288,3 +383,5 @@

*/
var name,
var stream = {},
name,
functions = [

@@ -308,2 +405,3 @@ 'chdir',

*/
for (name in functions) {

@@ -317,4 +415,25 @@ if (functions.hasOwnProperty(name)) {

process.stdout = {/* should be console */};
process.stderr = {/* should be console */};
/*
* build a simple stream object
*/
stream.writable = true;
stream.destroy = function() {};
stream.destroySoon = function() {};
stream.write = function(string) {
if (typeof string === 'Buffer') {
string = string.toString();
}
console.log(string);
};
stream.end = function(string) {
stream.write(string);
};
/*
* Supply data where we can.
*/
process.stdout = stream;
process.stderr = stream;
process.stdin = {/* should be console */};

@@ -327,3 +446,3 @@ process.argv = [];

process.env = '';
process.version = '0.0.1';
process.version = '0.0.2';
process.versions = {

@@ -330,0 +449,0 @@ 'knot': process.version,

@@ -0,2 +1,28 @@

// (The MIT License)
//
// Copyright (c) 2012 Richard S Allinson <rsa@mountainmansoftware.com>
//
// 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.
/*
* Load modules
*/
var fs = require('fs'),

@@ -6,4 +32,8 @@ path = require('path'),

/*
* Constants
*/
var PACKAGE = 'package.json',
URL_PREFIX = '/knot/';
KNOT_PREFIX = '/knot/';

@@ -90,2 +120,29 @@ /**

/*
* This function looks for a <dir>/package.json file. If one is found it then
* sees if there is a knot entry and each file it finds to the "modules" object.
*
* "<dir>/package.json"
*
* knot: {
* client: [
* <relative_path>
* ]
* }
*
* "modules"
*
* {
* <uri>: {
* name: <module_name>/<relative_path>
* path: <abs_path_to_file>
* uri: <uri>
* }
* }
*
* @param {string} dir
* @param {Object} modules
* @api private
*/
function parsePackage(dir, modules) {

@@ -115,3 +172,3 @@

uri = (name ? name + '/' : '' ) + files[file] + '.js';
modules[URL_PREFIX + uri] = {
modules[KNOT_PREFIX + uri] = {
name: (name ? name + '/' : '' ) + files[file],

@@ -125,13 +182,22 @@ path: path.join(dir, files[file] + '.js'),

// if (pack.knot.main) {
// uri = name + '/' + pack.knot.main + '.js';
// modules[URL_PREFIX + uri] = {
// name: name,
// path: path.join(dir, pack.knot.main + '.js'),
// uri: uri
// };
// }
if (pack.knot.main) {
uri = (name ? name + '/' : '' ) + files[file] + '.js';
modules[KNOT_PREFIX + uri] = {
name: name,
path: path.join(dir, files[file] + '.js'),
uri: uri
};
}
}
}
/*
* From the given directory this function walks the directory tree to find
* any "package.json" files. For each one found it calls "parsePackage()".
*
* @param {string} dir
* @param {Object} modules
* @api private
*/
function findModules(dir, modules) {

@@ -164,3 +230,3 @@

/**
* Returns a connect middleware funciton.
* Returns the knot connect middleware funciton.
*

@@ -173,7 +239,7 @@ * @param {ServerRequest} root

exports = module.exports = function(root, options){
var modules = {};
// set options if not provided
options = options || {};
// root required

@@ -183,6 +249,4 @@ if (!root) {

}
// Set the root
options.root = root;
// Find all public modules

@@ -193,4 +257,2 @@ findModules(options.root, modules);

// console.log(modules);
return function(req, res, next) {

@@ -197,0 +259,0 @@ options.path = req.url;

{
"name": "knot",
"description": "A client side Node experiment.",
"version": "0.0.1",
"version": "0.0.2",
"author": {

@@ -6,0 +6,0 @@ "name": "Richard S Allinson",

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