corrade-nucleus-nucleons

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 19  →  ?path2? @ 20
/script-kiddie/002_script_kiddie/script-kiddie/node_modules/sigmund/LICENSE
@@ -0,0 +1,15 @@
The ISC License
 
Copyright (c) Isaac Z. Schlueter and Contributors
 
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
 
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/script-kiddie/002_script_kiddie/script-kiddie/node_modules/sigmund/README.md
@@ -0,0 +1,53 @@
# sigmund
 
Quick and dirty signatures for Objects.
 
This is like a much faster `deepEquals` comparison, which returns a
string key suitable for caches and the like.
 
## Usage
 
```javascript
function doSomething (someObj) {
var key = sigmund(someObj, maxDepth) // max depth defaults to 10
var cached = cache.get(key)
if (cached) return cached
 
var result = expensiveCalculation(someObj)
cache.set(key, result)
return result
}
```
 
The resulting key will be as unique and reproducible as calling
`JSON.stringify` or `util.inspect` on the object, but is much faster.
In order to achieve this speed, some differences are glossed over.
For example, the object `{0:'foo'}` will be treated identically to the
array `['foo']`.
 
Also, just as there is no way to summon the soul from the scribblings
of a cocaine-addled psychoanalyst, there is no way to revive the object
from the signature string that sigmund gives you. In fact, it's
barely even readable.
 
As with `util.inspect` and `JSON.stringify`, larger objects will
produce larger signature strings.
 
Because sigmund is a bit less strict than the more thorough
alternatives, the strings will be shorter, and also there is a
slightly higher chance for collisions. For example, these objects
have the same signature:
 
var obj1 = {a:'b',c:/def/,g:['h','i',{j:'',k:'l'}]}
var obj2 = {a:'b',c:'/def/',g:['h','i','{jkl']}
 
Like a good Freudian, sigmund is most effective when you already have
some understanding of what you're looking for. It can help you help
yourself, but you must be willing to do some work as well.
 
Cycles are handled, and cyclical objects are silently omitted (though
the key is included in the signature output.)
 
The second argument is the maximum depth, which defaults to 10,
because that is the maximum object traversal depth covered by most
insurance carriers.
/script-kiddie/002_script_kiddie/script-kiddie/node_modules/sigmund/bench.js
@@ -0,0 +1,283 @@
// different ways to id objects
// use a req/res pair, since it's crazy deep and cyclical
 
// sparseFE10 and sigmund are usually pretty close, which is to be expected,
// since they are essentially the same algorithm, except that sigmund handles
// regular expression objects properly.
 
 
var http = require('http')
var util = require('util')
var sigmund = require('./sigmund.js')
var sreq, sres, creq, cres, test
 
http.createServer(function (q, s) {
sreq = q
sres = s
sres.end('ok')
this.close(function () { setTimeout(function () {
start()
}, 200) })
}).listen(1337, function () {
creq = http.get({ port: 1337 })
creq.on('response', function (s) { cres = s })
})
 
function start () {
test = [sreq, sres, creq, cres]
// test = sreq
// sreq.sres = sres
// sreq.creq = creq
// sreq.cres = cres
 
for (var i in exports.compare) {
console.log(i)
var hash = exports.compare[i]()
console.log(hash)
console.log(hash.length)
console.log('')
}
 
require('bench').runMain()
}
 
function customWs (obj, md, d) {
d = d || 0
var to = typeof obj
if (to === 'undefined' || to === 'function' || to === null) return ''
if (d > md || !obj || to !== 'object') return ('' + obj).replace(/[\n ]+/g, '')
 
if (Array.isArray(obj)) {
return obj.map(function (i, _, __) {
return customWs(i, md, d + 1)
}).reduce(function (a, b) { return a + b }, '')
}
 
var keys = Object.keys(obj)
return keys.map(function (k, _, __) {
return k + ':' + customWs(obj[k], md, d + 1)
}).reduce(function (a, b) { return a + b }, '')
}
 
function custom (obj, md, d) {
d = d || 0
var to = typeof obj
if (to === 'undefined' || to === 'function' || to === null) return ''
if (d > md || !obj || to !== 'object') return '' + obj
 
if (Array.isArray(obj)) {
return obj.map(function (i, _, __) {
return custom(i, md, d + 1)
}).reduce(function (a, b) { return a + b }, '')
}
 
var keys = Object.keys(obj)
return keys.map(function (k, _, __) {
return k + ':' + custom(obj[k], md, d + 1)
}).reduce(function (a, b) { return a + b }, '')
}
 
function sparseFE2 (obj, maxDepth) {
var seen = []
var soFar = ''
function ch (v, depth) {
if (depth > maxDepth) return
if (typeof v === 'function' || typeof v === 'undefined') return
if (typeof v !== 'object' || !v) {
soFar += v
return
}
if (seen.indexOf(v) !== -1 || depth === maxDepth) return
seen.push(v)
soFar += '{'
Object.keys(v).forEach(function (k, _, __) {
// pseudo-private values. skip those.
if (k.charAt(0) === '_') return
var to = typeof v[k]
if (to === 'function' || to === 'undefined') return
soFar += k + ':'
ch(v[k], depth + 1)
})
soFar += '}'
}
ch(obj, 0)
return soFar
}
 
function sparseFE (obj, maxDepth) {
var seen = []
var soFar = ''
function ch (v, depth) {
if (depth > maxDepth) return
if (typeof v === 'function' || typeof v === 'undefined') return
if (typeof v !== 'object' || !v) {
soFar += v
return
}
if (seen.indexOf(v) !== -1 || depth === maxDepth) return
seen.push(v)
soFar += '{'
Object.keys(v).forEach(function (k, _, __) {
// pseudo-private values. skip those.
if (k.charAt(0) === '_') return
var to = typeof v[k]
if (to === 'function' || to === 'undefined') return
soFar += k
ch(v[k], depth + 1)
})
}
ch(obj, 0)
return soFar
}
 
function sparse (obj, maxDepth) {
var seen = []
var soFar = ''
function ch (v, depth) {
if (depth > maxDepth) return
if (typeof v === 'function' || typeof v === 'undefined') return
if (typeof v !== 'object' || !v) {
soFar += v
return
}
if (seen.indexOf(v) !== -1 || depth === maxDepth) return
seen.push(v)
soFar += '{'
for (var k in v) {
// pseudo-private values. skip those.
if (k.charAt(0) === '_') continue
var to = typeof v[k]
if (to === 'function' || to === 'undefined') continue
soFar += k
ch(v[k], depth + 1)
}
}
ch(obj, 0)
return soFar
}
 
function noCommas (obj, maxDepth) {
var seen = []
var soFar = ''
function ch (v, depth) {
if (depth > maxDepth) return
if (typeof v === 'function' || typeof v === 'undefined') return
if (typeof v !== 'object' || !v) {
soFar += v
return
}
if (seen.indexOf(v) !== -1 || depth === maxDepth) return
seen.push(v)
soFar += '{'
for (var k in v) {
// pseudo-private values. skip those.
if (k.charAt(0) === '_') continue
var to = typeof v[k]
if (to === 'function' || to === 'undefined') continue
soFar += k + ':'
ch(v[k], depth + 1)
}
soFar += '}'
}
ch(obj, 0)
return soFar
}
 
 
function flatten (obj, maxDepth) {
var seen = []
var soFar = ''
function ch (v, depth) {
if (depth > maxDepth) return
if (typeof v === 'function' || typeof v === 'undefined') return
if (typeof v !== 'object' || !v) {
soFar += v
return
}
if (seen.indexOf(v) !== -1 || depth === maxDepth) return
seen.push(v)
soFar += '{'
for (var k in v) {
// pseudo-private values. skip those.
if (k.charAt(0) === '_') continue
var to = typeof v[k]
if (to === 'function' || to === 'undefined') continue
soFar += k + ':'
ch(v[k], depth + 1)
soFar += ','
}
soFar += '}'
}
ch(obj, 0)
return soFar
}
 
exports.compare =
{
// 'custom 2': function () {
// return custom(test, 2, 0)
// },
// 'customWs 2': function () {
// return customWs(test, 2, 0)
// },
'JSON.stringify (guarded)': function () {
var seen = []
return JSON.stringify(test, function (k, v) {
if (typeof v !== 'object' || !v) return v
if (seen.indexOf(v) !== -1) return undefined
seen.push(v)
return v
})
},
 
'flatten 10': function () {
return flatten(test, 10)
},
 
// 'flattenFE 10': function () {
// return flattenFE(test, 10)
// },
 
'noCommas 10': function () {
return noCommas(test, 10)
},
 
'sparse 10': function () {
return sparse(test, 10)
},
 
'sparseFE 10': function () {
return sparseFE(test, 10)
},
 
'sparseFE2 10': function () {
return sparseFE2(test, 10)
},
 
sigmund: function() {
return sigmund(test, 10)
},
 
 
// 'util.inspect 1': function () {
// return util.inspect(test, false, 1, false)
// },
// 'util.inspect undefined': function () {
// util.inspect(test)
// },
// 'util.inspect 2': function () {
// util.inspect(test, false, 2, false)
// },
// 'util.inspect 3': function () {
// util.inspect(test, false, 3, false)
// },
// 'util.inspect 4': function () {
// util.inspect(test, false, 4, false)
// },
// 'util.inspect Infinity': function () {
// util.inspect(test, false, Infinity, false)
// }
}
 
/** results
**/
/script-kiddie/002_script_kiddie/script-kiddie/node_modules/sigmund/package.json
@@ -0,0 +1,93 @@
{
"_args": [
[
{
"raw": "sigmund@^1.0.1",
"scope": null,
"escapedName": "sigmund",
"name": "sigmund",
"rawSpec": "^1.0.1",
"spec": ">=1.0.1 <2.0.0",
"type": "range"
},
"/Users/evacomaroski/Documents/Development/corrade-nucleus-nucleons/script-kiddie/002_script_kiddie/script-kiddie/node_modules/editorconfig"
]
],
"_from": "sigmund@>=1.0.1 <2.0.0",
"_id": "sigmund@1.0.1",
"_inCache": true,
"_location": "/sigmund",
"_nodeVersion": "2.0.1",
"_npmUser": {
"name": "isaacs",
"email": "isaacs@npmjs.com"
},
"_npmVersion": "2.10.0",
"_phantomChildren": {},
"_requested": {
"raw": "sigmund@^1.0.1",
"scope": null,
"escapedName": "sigmund",
"name": "sigmund",
"rawSpec": "^1.0.1",
"spec": ">=1.0.1 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/editorconfig"
],
"_resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz",
"_shasum": "3ff21f198cad2175f9f3b781853fd94d0d19b590",
"_shrinkwrap": null,
"_spec": "sigmund@^1.0.1",
"_where": "/Users/evacomaroski/Documents/Development/corrade-nucleus-nucleons/script-kiddie/002_script_kiddie/script-kiddie/node_modules/editorconfig",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"bugs": {
"url": "https://github.com/isaacs/sigmund/issues"
},
"dependencies": {},
"description": "Quick and dirty signatures for Objects.",
"devDependencies": {
"tap": "~0.3.0"
},
"directories": {
"test": "test"
},
"dist": {
"shasum": "3ff21f198cad2175f9f3b781853fd94d0d19b590",
"tarball": "http://grimore.org:4873/sigmund/-/sigmund-1.0.1.tgz"
},
"gitHead": "527f97aa5bb253d927348698c0cd3bb267d098c6",
"homepage": "https://github.com/isaacs/sigmund#readme",
"keywords": [
"object",
"signature",
"key",
"data",
"psychoanalysis"
],
"license": "ISC",
"main": "sigmund.js",
"maintainers": [
{
"name": "isaacs",
"email": "i@izs.me"
}
],
"name": "sigmund",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/sigmund.git"
},
"scripts": {
"bench": "node bench.js",
"test": "tap test/*.js"
},
"version": "1.0.1"
}
/script-kiddie/002_script_kiddie/script-kiddie/node_modules/sigmund/sigmund.js
@@ -0,0 +1,39 @@
module.exports = sigmund
function sigmund (subject, maxSessions) {
maxSessions = maxSessions || 10;
var notes = [];
var analysis = '';
var RE = RegExp;
 
function psychoAnalyze (subject, session) {
if (session > maxSessions) return;
 
if (typeof subject === 'function' ||
typeof subject === 'undefined') {
return;
}
 
if (typeof subject !== 'object' || !subject ||
(subject instanceof RE)) {
analysis += subject;
return;
}
 
if (notes.indexOf(subject) !== -1 || session === maxSessions) return;
 
notes.push(subject);
analysis += '{';
Object.keys(subject).forEach(function (issue, _, __) {
// pseudo-private values. skip those.
if (issue.charAt(0) === '_') return;
var to = typeof subject[issue];
if (to === 'function' || to === 'undefined') return;
analysis += issue;
psychoAnalyze(subject[issue], session + 1);
});
}
psychoAnalyze(subject, 0);
return analysis;
}
 
// vim: set softtabstop=4 shiftwidth=4:
/script-kiddie/002_script_kiddie/script-kiddie/node_modules/sigmund/test/basic.js
@@ -0,0 +1,24 @@
var test = require('tap').test
var sigmund = require('../sigmund.js')
 
 
// occasionally there are duplicates
// that's an acceptable edge-case. JSON.stringify and util.inspect
// have some collision potential as well, though less, and collision
// detection is expensive.
var hash = '{abc/def/g{0h1i2{jkl'
var obj1 = {a:'b',c:/def/,g:['h','i',{j:'',k:'l'}]}
var obj2 = {a:'b',c:'/def/',g:['h','i','{jkl']}
 
var obj3 = JSON.parse(JSON.stringify(obj1))
obj3.c = /def/
obj3.g[2].cycle = obj3
var cycleHash = '{abc/def/g{0h1i2{jklcycle'
 
test('basic', function (t) {
t.equal(sigmund(obj1), hash)
t.equal(sigmund(obj2), hash)
t.equal(sigmund(obj3), cycleHash)
t.end()
})