Archived
Updated to the new database schema
Signed-off-by: walamana <joniogerg@gmail.com>
This commit is contained in:
1 parent
27c53fe8d0
commit
f62311d20a
17 files changed
+2545
-66
No files matched your search
Vendored
+4
-1
@@ -7,7 +7,10 @@
|
|||||||
"name": "Launch Program",
|
"name": "Launch Program",
|
||||||
"program": "${workspaceRoot}/app.js",
|
"program": "${workspaceRoot}/app.js",
|
||||||
"env": {"PORT": "3000"},
|
"env": {"PORT": "3000"},
|
||||||
"cwd": "${workspaceRoot}"
|
"cwd": "${workspaceRoot}",
|
||||||
|
"args": [
|
||||||
|
"--harmony"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ var path = require("path");
|
|||||||
var errorHandler = require("errorhandler");
|
var errorHandler = require("errorhandler");
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
|
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
res.setHeader("Access-Control-Allow-Origin", "*");
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
||||||
@@ -20,7 +21,7 @@ var cause;
|
|||||||
var con = mysql.createConnection({
|
var con = mysql.createConnection({
|
||||||
host: "localhost",
|
host: "localhost",
|
||||||
user: "minis",
|
user: "minis",
|
||||||
password: "Wnc4q_75",
|
password: "lOkw83^2",
|
||||||
database: "minis"
|
database: "minis"
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -35,49 +36,42 @@ con.connect(err => {
|
|||||||
|
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
|
console.log(con);
|
||||||
res.send("Welcome to the miniplan api!");
|
res.send("Welcome to the miniplan api!");
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/login', (req, res) => {
|
app.get('/login', (req, res) => {
|
||||||
var username = req.query.username;
|
var id = req.query.id;
|
||||||
var password = req.query.password;
|
var password = req.query.password;
|
||||||
|
|
||||||
if(username == undefined || password == undefined){
|
if(id == undefined || password == undefined){
|
||||||
res.send({success: false, error: "Missing parameters"});
|
res.send({success: false, error: "Missing parameters"});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
username = username.toLowerCase();
|
id = id.toLowerCase();
|
||||||
|
|
||||||
/*con.query("SELECT UserToken FROM ministranten WHERE Username='" + username + "'", (err, result) => {
|
con.query("SELECT PASSWORT, USERNAME FROM ministranten WHERE (USERNAME='" + id + "' OR EMAIL='" + id + "')", (err, result) => {
|
||||||
if(result[0]["UserToken"] == req.cookies.loginToken){
|
if (err) throw err;
|
||||||
res.send({success: true});
|
if(password == result[0]["PASSWORT"]){
|
||||||
}else{*/
|
var usertoken = uuid();
|
||||||
con.query("SELECT Passwort FROM ministranten WHERE Username='" + username + "'", (err, result) => {
|
res.cookie("loginToken", usertoken);
|
||||||
if (err) throw err;
|
res.cookie("user", result[0]["USERNAME"]);
|
||||||
if(password == result[0]["Passwort"]){
|
con.query("UPDATE `ministranten` SET `USER_TOKEN` = '" + usertoken + "' WHERE `ministranten`.`USERNAME` = '" + result[0]["USERNAME"] + "';");
|
||||||
var usertoken = uuid();
|
res.send({success: true, token: usertoken});
|
||||||
res.cookie("loginToken", usertoken);
|
}else{
|
||||||
res.cookie("user", username);
|
res.send({success: false});
|
||||||
con.query("UPDATE `ministranten` SET `UserToken` = '" + usertoken + "' WHERE `ministranten`.`Username` = '" + username + "';");
|
}
|
||||||
res.send({success: true, token: usertoken});
|
});
|
||||||
}else{
|
|
||||||
res.send({success: false});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/*}
|
|
||||||
});*/
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/logout", (req, res) => {
|
app.get("/logout", (req, res) => {
|
||||||
var token = req.cookies.loginToken;
|
var token = req.cookies.loginToken;
|
||||||
var user = req.cookies.user;
|
var user = req.cookies.user;
|
||||||
|
|
||||||
con.query("SELECT UserToken FROM ministranten WHERE Username='" + user + "'", (err, result) => {
|
tokenIsValid(user, token).then(valid => {
|
||||||
if (err) throw err;
|
if(valid){
|
||||||
|
con.query("UPDATE `ministranten` SET `USER_TOKEN` = '' WHERE `ministranten`.`USERNAME` = '" + user + "';");
|
||||||
if(result[0]["UserToken"] != "" && result[0]["UserToken"] == token){
|
|
||||||
con.query("UPDATE `ministranten` SET `UserToken` = '' WHERE `ministranten`.`Username` = '" + user + "';");
|
|
||||||
res.cookie("loginToken", "");
|
res.cookie("loginToken", "");
|
||||||
res.cookie("user", "");
|
res.cookie("user", "");
|
||||||
res.send({success: true});
|
res.send({success: true});
|
||||||
@@ -89,70 +83,120 @@ app.get("/logout", (req, res) => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/user/:user/update", (req, res) => {
|
app.get("/loggedIn", (req, res) => {
|
||||||
|
var token = req.cookies.loginToken;
|
||||||
|
var user = req.cookies.user;
|
||||||
|
|
||||||
|
tokenIsValid(user, token).then(valid => {
|
||||||
|
if(valid){
|
||||||
|
res.send({success: true, loggedIn: true, user: user});
|
||||||
|
}else{
|
||||||
|
res.send({success: true, loggedIn: false, user: user});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* WIP
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.get("/:user/update", (req, res) => {
|
||||||
|
var token = req.cookies.loginToken;
|
||||||
|
var user = req.params.user;
|
||||||
|
var changes = JSON.parse(req.query.changes);
|
||||||
|
|
||||||
|
|
||||||
|
tokenIsValid(req.cookies.user, token).then(valid => {
|
||||||
|
if(valid){
|
||||||
|
if(req.cookies.user != "admin" && req.cookies.user != user){
|
||||||
|
res.send({success: false, error: "Unauthorized"});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Changing for " + user + " as " + req.cookies.user + " following states: ");
|
||||||
|
console.log(changes);
|
||||||
|
for(var i = 0; i < Object.keys(changes).length; i++){
|
||||||
|
var gdID = Object.keys(changes)[i];
|
||||||
|
var anwesenheit = changes[Object.keys(changes)[i]];
|
||||||
|
con.query("INSERT INTO `anwesenheit` (USERNAME, gottesdienst_ID, ANWESENHEIT) VALUES('" + user + "', " + gdID + ", " + anwesenheit + ") ON DUPLICATE KEY UPDATE USERNAME='" + user + "', gottesdienst_ID=" + gdID + ", ANWESENHEIT=" + anwesenheit + "")
|
||||||
|
}
|
||||||
|
|
||||||
|
res.send({success: true});
|
||||||
|
}else{
|
||||||
|
console.log("Unauthorized not valid");
|
||||||
|
res.send({success: false, error: "Unauthorized"});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
app.get("/gottesdienste", (req, res) => {
|
app.get("/gottesdienste", (req, res) => {
|
||||||
var groupid = req.params.groupid;
|
var groupid = req.params.groupid;
|
||||||
con.query("SELECT ID from gottesdienstGruppe ORDER BY ID DESC LIMIT 1", (err, result) => {
|
con.query("SELECT ID from gruppe ORDER BY ID DESC LIMIT 1", (err, result) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
con.query("SELECT * from gottesdienste WHERE GruppeID='" + result[0]["ID"] + "' ORDER BY `gottesdienste`.`Datum` ASC LIMIT 0 , 30 ", (err, result) => {
|
con.query("SELECT * from gottesdienst WHERE gruppe_ID='" + result[0]["ID"] + "' ORDER BY `gottesdienst`.`DATUM` ASC LIMIT 0 , 30 ", (err, result) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
res.send(JSON.stringify(result));
|
res.send(JSON.stringify(result));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/gottesdienste/:groupid", (req, res) => {
|
app.get("/gottesdienste/:groupid", (req, res) => {
|
||||||
var groupid = req.params.groupid;
|
var groupid = req.params.groupid;
|
||||||
con.query("SELECT * from gottesdienste WHERE GruppeID='" + groupid + "' ORDER BY `gottesdienste`.`Datum` ASC LIMIT 0 , 30", (err, result) => {
|
con.query("SELECT * from gottesdienst WHERE gruppe_ID='" + groupid + "' ORDER BY `gottesdienst`.`DATUM` ASC LIMIT 0 , 30", (err, result) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
res.send(JSON.stringify(result));
|
res.send(JSON.stringify(result));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/groups", (req, res) => {
|
app.get("/groups", (req, res) => {
|
||||||
con.query("SELECT * from gottesdienstGruppe ORDER BY `gottesdienstGruppe`.`ID` DESC LIMIT 0, 5", (err, result) => {
|
con.query("SELECT * from gruppe ORDER BY `gruppe`.`ID` DESC LIMIT 0, 5", (err, result) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
res.send(JSON.stringify(result));
|
res.send(JSON.stringify(result));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/ministranten", (req, res) =>{
|
app.get("/ministranten", (req, res) =>{
|
||||||
con.query("SELECT UserToken FROM ministranten WHERE UserToken='" + req.cookies.loginToken + "'", (err, result) => {
|
tokenIsValid(req.cookies.user, req.cookies.loginToken).then(valid => {
|
||||||
var loggedIn = result.length == 1;
|
con.query("SELECT `ministranten`.`USERNAME`, `ministranten`.`VORNAME`, `ministranten`.`NACHNAME`, `anwesenheit`.`ANWESENHEIT`, `anwesenheit`.`gottesdienst_ID` FROM `ministranten` LEFT JOIN `anwesenheit` ON `anwesenheit`.`USERNAME` = `ministranten`.`USERNAME` ORDER BY `ministranten`.`NACHNAME`, `ministranten`.`VORNAME`, `anwesenheit`.`gottesdienst_ID` DESC LIMIT 30", (err, results) => {
|
||||||
con.query("SELECT Name, Username FROM `ministranten`", (err, result) => {
|
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
var minis = result;
|
var minis = [];
|
||||||
|
|
||||||
var finished = 0;
|
var curMini;
|
||||||
|
for(var i = 0; i < results.length; i++){
|
||||||
|
|
||||||
minis.splice(0, 1);
|
var result = results[i];
|
||||||
for(var i = 0; i < minis.length; i++){
|
if(result["USERNAME"] == "admin"){
|
||||||
attachToMini(minis[i], i, (mini, pos) => {
|
continue;
|
||||||
minis[pos] = mini;
|
}
|
||||||
finished++;
|
if(!curMini || curMini.username != result["USERNAME"]){
|
||||||
if(finished == minis.length){
|
if(curMini != undefined || curMini != null){
|
||||||
if(!loggedIn){
|
minis.push(curMini);
|
||||||
for(var i = 0; i < minis.length; i++){
|
|
||||||
if(minis[i]["Name"] == "admin"){
|
|
||||||
minis.splice(0, 1);
|
|
||||||
i--;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
minis[i]["Name"] = minis[i]["Name"].split(" ")[0].substring(0, 1) + ". " + minis[i]["Name"].split(" ")[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res.send(JSON.stringify(minis));
|
|
||||||
}
|
}
|
||||||
});
|
curMini = {
|
||||||
|
firstname: result["VORNAME"],
|
||||||
|
lastname: valid ? result["NACHNAME"] : result["NACHNAME"].substring(0, 1) + ".",
|
||||||
|
username: result["USERNAME"],
|
||||||
|
registered: {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
curMini.registered[result["gottesdienst_ID"]] = result["ANWESENHEIT"];
|
||||||
}
|
}
|
||||||
|
minis.push(curMini);
|
||||||
|
|
||||||
|
res.send(JSON.stringify(minis));
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var attachToMini = function(mini, pos, then){
|
var attachToMini = function(mini, pos, then){
|
||||||
@@ -161,7 +205,6 @@ var attachToMini = function(mini, pos, then){
|
|||||||
if(data == null){
|
if(data == null){
|
||||||
then(mini, pos);
|
then(mini, pos);
|
||||||
}
|
}
|
||||||
console.log(data);
|
|
||||||
for(var j = 0; j < data.length; j++){
|
for(var j = 0; j < data.length; j++){
|
||||||
|
|
||||||
mini.registered[j] = {
|
mini.registered[j] = {
|
||||||
@@ -179,18 +222,30 @@ console.log("Starting api-server on " + process.env.PORT);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function tokenIsValid(username, token){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
con.query("SELECT USER_TOKEN FROM ministranten WHERE USERNAME='" + username + "'", (err, result) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
if(result.length == 0){
|
||||||
|
resolve(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(result[0]["USER_TOKEN"] != "" && result[0]["USER_TOKEN"] == token){
|
||||||
function isConnected(){
|
resolve(true);
|
||||||
if(con.isConnected){
|
}else{
|
||||||
return true;
|
resolve(false);
|
||||||
}else{
|
}
|
||||||
return false;
|
});
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function removeFromArrayByValue(value, array) {
|
function removeFromArrayByValue(value, array) {
|
||||||
var index = array.indexOf(value);
|
var index = array.indexOf(value);
|
||||||
if(index > -1){
|
if(index > -1){
|
||||||
|
|||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"shadow": "inner",
|
||||||
|
"indent": 1,
|
||||||
|
|
||||||
|
"camelcase": false,
|
||||||
|
"eqeqeq": true,
|
||||||
|
"eqnull": true,
|
||||||
|
"freeze": true,
|
||||||
|
"funcscope": true,
|
||||||
|
"newcap": true,
|
||||||
|
"noarg": true,
|
||||||
|
"noempty": true,
|
||||||
|
"nonbsp": true,
|
||||||
|
"unused": "vars",
|
||||||
|
"undef": true,
|
||||||
|
"scripturl": true,
|
||||||
|
"loopfunc": true,
|
||||||
|
"strict": "implied",
|
||||||
|
"validthis": true,
|
||||||
|
|
||||||
|
"esnext": true,
|
||||||
|
"globals": {},
|
||||||
|
"browser": true,
|
||||||
|
"devel": true,
|
||||||
|
"mocha": true,
|
||||||
|
"node": true,
|
||||||
|
"jquery": true
|
||||||
|
}
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2.3.0
|
||||||
|
- Constructor now supports a 2D array 2D of key-value pair. Thanks @ulikoehler
|
||||||
|
- Renamed `remove()` to `delete()`. `remove()` is now deprecated and kept temporarily. Thanks @ulikoehler
|
||||||
|
- Added `.size` member. `count()` is now deprecated and kept temporarily. Thanks @ulikoehler
|
||||||
|
|
||||||
|
## 2.2.0
|
||||||
|
- Added entries() method to hashmaps. Thanks @ulikoehler
|
||||||
|
|
||||||
|
## 2.1.0
|
||||||
|
- support ECMA 5 non-conformant behaviour of Microsoft edge #27. Thanks @freddiecoleman
|
||||||
|
|
||||||
|
## 2.0.6
|
||||||
|
- Names of chained methods is hardcoded rather than using the "return" trick. Fixes bug when minified, thanks @fresheneesz.
|
||||||
|
- Added jshint to be run before any commit
|
||||||
|
|
||||||
|
## 2.0.5
|
||||||
|
- count() is now O(1), thanks @qbolec
|
||||||
|
|
||||||
|
## 2.0.4
|
||||||
|
- hasOwnProperty() is used to check for the internal expando, thanks @psionski
|
||||||
|
|
||||||
|
## 2.0.3
|
||||||
|
- forEach method accepts a context as 2nd argument, thanks @mvayngrib
|
||||||
|
|
||||||
|
## 2.0.2
|
||||||
|
- Make collisions rarer
|
||||||
|
|
||||||
|
## 2.0.1
|
||||||
|
- AMD CommonJS export is now compatible
|
||||||
|
|
||||||
|
## 2.0.0
|
||||||
|
- Added chaining to all methods with no returned value
|
||||||
|
- Added multi() method
|
||||||
|
- Added clone() method
|
||||||
|
- Added copy() method
|
||||||
|
- constructor accepts one argument for cloning or several for multi()
|
||||||
|
|
||||||
|
## 1.2.0
|
||||||
|
- Added search() method, thanks @rafalwrzeszcz
|
||||||
|
|
||||||
|
## 1.1.0
|
||||||
|
- AMD support, thanks @khrome
|
||||||
|
|
||||||
|
## 1.0.1
|
||||||
|
- forEach() callback receives the hashmap as `this`
|
||||||
|
- Added keys()
|
||||||
|
- Added values()
|
||||||
|
|
||||||
|
## 1.0.0
|
||||||
|
- First release
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2012 Ariel Flesler <aflesler@gmail.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.
|
||||||
+170
@@ -0,0 +1,170 @@
|
|||||||
|
# HashMap Class for JavaScript
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
[](https://npmjs.org/package/hashmap)
|
||||||
|
|
||||||
|
Using [npm](https://npmjs.org/package/hashmap):
|
||||||
|
|
||||||
|
$ npm install hashmap
|
||||||
|
|
||||||
|
Using bower:
|
||||||
|
|
||||||
|
$ bower install hashmap
|
||||||
|
|
||||||
|
You can download the last stable version from the [releases page](https://github.com/flesler/hashmap/releases).
|
||||||
|
|
||||||
|
If you like risk, you can download the [latest master version](https://raw.github.com/flesler/hashmap/master/hashmap.js), it's usually stable.
|
||||||
|
|
||||||
|
To run the tests:
|
||||||
|
|
||||||
|
$ npm test
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
This project provides a `HashMap` class that works both on __Node.js__ and the __browser__.
|
||||||
|
HashMap instances __store key/value pairs__ allowing __keys of any type__.
|
||||||
|
|
||||||
|
Unlike regular objects, __keys will not be stringified__. For example numbers and strings won't be mixed, you can pass `Date`'s, `RegExp`'s, DOM Elements, anything! (even `null` and `undefined`)
|
||||||
|
|
||||||
|
## HashMap constructor overloads
|
||||||
|
- `new HashMap()` creates an empty hashmap
|
||||||
|
- `new HashMap(map:HashMap)` creates a hashmap with the key-value pairs of `map`
|
||||||
|
- `new HashMap(arr:Array)` creates a hashmap from the 2D key-value array `arr`, e.g. `[['key1','val1'], ['key2','val2']]`
|
||||||
|
- `new HashMap(key:*, value:*, key2:*, value2:*, ...)` creates a hashmap with several key-value pairs
|
||||||
|
|
||||||
|
## HashMap methods
|
||||||
|
|
||||||
|
- `get(key:*) : *` returns the value stored for that key.
|
||||||
|
- `set(key:*, value:*) : HashMap` stores a key-value pair
|
||||||
|
- `multi(key:*, value:*, key2:*, value2:*, ...) : HashMap` stores several key-value pairs
|
||||||
|
- `copy(other:HashMap) : HashMap` copies all key-value pairs from other to this instance
|
||||||
|
- `has(key:*) : Boolean` returns whether a key is set on the hashmap
|
||||||
|
- `search(value:*) : *` returns key under which given value is stored (`null` if not found)
|
||||||
|
- `delete(key:*) : HashMap` deletes a key-value pair by key
|
||||||
|
- `remove(key:*) : HashMap` Alias for `delete(key:*)` *(deprecated)*
|
||||||
|
- `type(key:*) : String` returns the data type of the provided key (used internally)
|
||||||
|
- `keys() : Array<*>` returns an array with all the registered keys
|
||||||
|
- `values() : Array<*>` returns an array with all the values
|
||||||
|
- `entries() : Array<[*,*]>` returns an array with [key,value] pairs
|
||||||
|
- `size : Number` the amount of key-value pairs
|
||||||
|
- `count() : Number` returns the amount of key-value pairs *(deprecated)*
|
||||||
|
- `clear() : HashMap` deletes all the key-value pairs on the hashmap
|
||||||
|
- `clone() : HashMap` creates a new hashmap with all the key-value pairs of the original
|
||||||
|
- `hash(key:*) : String` returns the stringified version of a key (used internally)
|
||||||
|
- `forEach(function(value, key)) : HashMap` iterates the pairs and calls the function for each one
|
||||||
|
|
||||||
|
### Method chaining
|
||||||
|
|
||||||
|
All methods that don't return something, will return the HashMap instance to enable chaining.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
Assume this for all examples below
|
||||||
|
|
||||||
|
```js
|
||||||
|
var map = new HashMap();
|
||||||
|
```
|
||||||
|
|
||||||
|
If you're using this within Node, you first need to import the class
|
||||||
|
|
||||||
|
```js
|
||||||
|
var HashMap = require('hashmap');
|
||||||
|
```
|
||||||
|
|
||||||
|
### Basic use case
|
||||||
|
|
||||||
|
```js
|
||||||
|
map.set("some_key", "some value");
|
||||||
|
map.get("some_key"); // --> "some value"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Map size / number of elements
|
||||||
|
|
||||||
|
```js
|
||||||
|
var map = new HashMap();
|
||||||
|
map.set("key1", "val1");
|
||||||
|
map.set("key2", "val2");
|
||||||
|
map.size; // -> 2
|
||||||
|
```
|
||||||
|
|
||||||
|
### Deleting key-value pairs
|
||||||
|
|
||||||
|
```js
|
||||||
|
map.set("some_key", "some value");
|
||||||
|
map.delete("some_key");
|
||||||
|
map.get("some_key"); // --> undefined
|
||||||
|
```
|
||||||
|
|
||||||
|
### No stringification
|
||||||
|
|
||||||
|
```js
|
||||||
|
map.set("1", "string one");
|
||||||
|
map.set(1, "number one");
|
||||||
|
map.get("1"); // --> "string one"
|
||||||
|
```
|
||||||
|
|
||||||
|
A regular `Object` used as a map would yield `"number one"`
|
||||||
|
|
||||||
|
### Objects as keys
|
||||||
|
|
||||||
|
```js
|
||||||
|
var key = {};
|
||||||
|
var key2 = {};
|
||||||
|
map.set(key, 123);
|
||||||
|
map.set(key2, 321);
|
||||||
|
map.get(key); // --> 123
|
||||||
|
```
|
||||||
|
A regular `Object` used as a map would yield `321`
|
||||||
|
|
||||||
|
### Iterating
|
||||||
|
|
||||||
|
```js
|
||||||
|
map.set(1, "test 1");
|
||||||
|
map.set(2, "test 2");
|
||||||
|
map.set(3, "test 3");
|
||||||
|
|
||||||
|
map.forEach(function(value, key) {
|
||||||
|
console.log(key + " : " + value);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Method chaining
|
||||||
|
|
||||||
|
```js
|
||||||
|
map
|
||||||
|
.set(1, "test 1")
|
||||||
|
.set(2, "test 2")
|
||||||
|
.set(3, "test 3")
|
||||||
|
.forEach(function(value, key) {
|
||||||
|
console.log(key + " : " + value);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## LICENSE
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2012 Ariel Flesler
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
## To-Do
|
||||||
|
|
||||||
|
* (?) Allow extending the hashing function in a AOP way or by passing a service
|
||||||
|
* Make tests work on the browser
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "hashmap",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"description": "HashMap Class for JavaScript",
|
||||||
|
"homepage": "https://github.com/flesler/hashmap",
|
||||||
|
"main": "./hashmap.js",
|
||||||
|
"dependencies": {},
|
||||||
|
"keywords": [
|
||||||
|
"hashmap",
|
||||||
|
"map",
|
||||||
|
"object",
|
||||||
|
"array",
|
||||||
|
"associative",
|
||||||
|
"javascript",
|
||||||
|
"nodejs",
|
||||||
|
"node",
|
||||||
|
"browser"
|
||||||
|
],
|
||||||
|
"author": {
|
||||||
|
"name": "Ariel Flesler",
|
||||||
|
"web": "https://github.com/flesler"
|
||||||
|
},
|
||||||
|
"ignore": [
|
||||||
|
"**/.*",
|
||||||
|
"node_modules",
|
||||||
|
"test",
|
||||||
|
"components"
|
||||||
|
]
|
||||||
|
}
|
||||||
+210
@@ -0,0 +1,210 @@
|
|||||||
|
/**
|
||||||
|
* HashMap - HashMap Class for JavaScript
|
||||||
|
* @author Ariel Flesler <aflesler@gmail.com>
|
||||||
|
* @version 2.0.6
|
||||||
|
* Homepage: https://github.com/flesler/hashmap
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function(factory) {
|
||||||
|
/* global define */
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
// AMD. Register as an anonymous module.
|
||||||
|
define([], factory);
|
||||||
|
} else if (typeof module === 'object') {
|
||||||
|
// Node js environment
|
||||||
|
var HashMap = module.exports = factory();
|
||||||
|
// Keep it backwards compatible
|
||||||
|
HashMap.HashMap = HashMap;
|
||||||
|
} else {
|
||||||
|
// Browser globals (this is window)
|
||||||
|
this.HashMap = factory();
|
||||||
|
}
|
||||||
|
}(function() {
|
||||||
|
|
||||||
|
function HashMap(other) {
|
||||||
|
this.clear();
|
||||||
|
switch (arguments.length) {
|
||||||
|
case 0: break;
|
||||||
|
case 1: {
|
||||||
|
if ('length' in other) {
|
||||||
|
// Flatten 2D array to alternating key-value array
|
||||||
|
multi(this, Array.prototype.concat.apply([], other));
|
||||||
|
} else { // Assumed to be a HashMap instance
|
||||||
|
this.copy(other);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: multi(this, arguments); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var proto = HashMap.prototype = {
|
||||||
|
constructor:HashMap,
|
||||||
|
|
||||||
|
get:function(key) {
|
||||||
|
var data = this._data[this.hash(key)];
|
||||||
|
return data && data[1];
|
||||||
|
},
|
||||||
|
|
||||||
|
set:function(key, value) {
|
||||||
|
// Store original key as well (for iteration)
|
||||||
|
var hash = this.hash(key);
|
||||||
|
if ( !(hash in this._data) ) {
|
||||||
|
this.size++;
|
||||||
|
}
|
||||||
|
this._data[hash] = [key, value];
|
||||||
|
},
|
||||||
|
|
||||||
|
multi:function() {
|
||||||
|
multi(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
copy:function(other) {
|
||||||
|
for (var hash in other._data) {
|
||||||
|
if ( !(hash in this._data) ) {
|
||||||
|
this.size++;
|
||||||
|
}
|
||||||
|
this._data[hash] = other._data[hash];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
has:function(key) {
|
||||||
|
return this.hash(key) in this._data;
|
||||||
|
},
|
||||||
|
|
||||||
|
search:function(value) {
|
||||||
|
for (var key in this._data) {
|
||||||
|
if (this._data[key][1] === value) {
|
||||||
|
return this._data[key][0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
|
||||||
|
delete:function(key) {
|
||||||
|
var hash = this.hash(key);
|
||||||
|
if ( hash in this._data ) {
|
||||||
|
this.size--;
|
||||||
|
delete this._data[hash];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
type:function(key) {
|
||||||
|
var str = Object.prototype.toString.call(key);
|
||||||
|
var type = str.slice(8, -1).toLowerCase();
|
||||||
|
// Some browsers yield DOMWindow or Window for null and undefined, works fine on Node
|
||||||
|
if (!key && (type === 'domwindow' || type === 'window')) {
|
||||||
|
return key + '';
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
},
|
||||||
|
|
||||||
|
keys:function() {
|
||||||
|
var keys = [];
|
||||||
|
this.forEach(function(_, key) { keys.push(key); });
|
||||||
|
return keys;
|
||||||
|
},
|
||||||
|
|
||||||
|
values:function() {
|
||||||
|
var values = [];
|
||||||
|
this.forEach(function(value) { values.push(value); });
|
||||||
|
return values;
|
||||||
|
},
|
||||||
|
|
||||||
|
entries:function() {
|
||||||
|
var entries = [];
|
||||||
|
this.forEach(function(value, key) { entries.push([key, value]); });
|
||||||
|
return entries;
|
||||||
|
},
|
||||||
|
|
||||||
|
// TODO: This is deprecated and will be deleted in a future version
|
||||||
|
count:function() {
|
||||||
|
return this.size;
|
||||||
|
},
|
||||||
|
|
||||||
|
clear:function() {
|
||||||
|
// TODO: Would Object.create(null) make any difference
|
||||||
|
this._data = {};
|
||||||
|
this.size = 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
clone:function() {
|
||||||
|
return new HashMap(this);
|
||||||
|
},
|
||||||
|
|
||||||
|
hash:function(key) {
|
||||||
|
switch (this.type(key)) {
|
||||||
|
case 'undefined':
|
||||||
|
case 'null':
|
||||||
|
case 'boolean':
|
||||||
|
case 'number':
|
||||||
|
case 'regexp':
|
||||||
|
return key + '';
|
||||||
|
|
||||||
|
case 'date':
|
||||||
|
return '♣' + key.getTime();
|
||||||
|
|
||||||
|
case 'string':
|
||||||
|
return '♠' + key;
|
||||||
|
|
||||||
|
case 'array':
|
||||||
|
var hashes = [];
|
||||||
|
for (var i = 0; i < key.length; i++) {
|
||||||
|
hashes[i] = this.hash(key[i]);
|
||||||
|
}
|
||||||
|
return '♥' + hashes.join('⁞');
|
||||||
|
|
||||||
|
default:
|
||||||
|
// TODO: Don't use expandos when Object.defineProperty is not available?
|
||||||
|
if (!key.hasOwnProperty('_hmuid_')) {
|
||||||
|
key._hmuid_ = ++HashMap.uid;
|
||||||
|
hide(key, '_hmuid_');
|
||||||
|
}
|
||||||
|
|
||||||
|
return '♦' + key._hmuid_;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
forEach:function(func, ctx) {
|
||||||
|
for (var key in this._data) {
|
||||||
|
var data = this._data[key];
|
||||||
|
func.call(ctx || this, data[1], data[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
HashMap.uid = 0;
|
||||||
|
|
||||||
|
//- Add chaining to all methods that don't return something
|
||||||
|
|
||||||
|
['set','multi','copy','delete','clear','forEach'].forEach(function(method) {
|
||||||
|
var fn = proto[method];
|
||||||
|
proto[method] = function() {
|
||||||
|
fn.apply(this, arguments);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
//- Backwards compatibility
|
||||||
|
|
||||||
|
// TODO: remove() is deprecated and will be deleted in a future version
|
||||||
|
HashMap.prototype.remove = HashMap.prototype.delete;
|
||||||
|
|
||||||
|
//- Utils
|
||||||
|
|
||||||
|
function multi(map, args) {
|
||||||
|
for (var i = 0; i < args.length; i += 2) {
|
||||||
|
map.set(args[i], args[i+1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide(obj, prop) {
|
||||||
|
// Make non iterable if supported
|
||||||
|
if (Object.defineProperty) {
|
||||||
|
Object.defineProperty(obj, prop, {enumerable:false});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return HashMap;
|
||||||
|
}));
|
||||||
+71
@@ -0,0 +1,71 @@
|
|||||||
|
{
|
||||||
|
"_from": "hashmap",
|
||||||
|
"_id": "hashmap@2.3.0",
|
||||||
|
"_inBundle": false,
|
||||||
|
"_integrity": "sha1-sT+2XafIul49uPwbjFuh0ASdryI=",
|
||||||
|
"_location": "/hashmap",
|
||||||
|
"_phantomChildren": {},
|
||||||
|
"_requested": {
|
||||||
|
"type": "tag",
|
||||||
|
"registry": true,
|
||||||
|
"raw": "hashmap",
|
||||||
|
"name": "hashmap",
|
||||||
|
"escapedName": "hashmap",
|
||||||
|
"rawSpec": "",
|
||||||
|
"saveSpec": null,
|
||||||
|
"fetchSpec": "latest"
|
||||||
|
},
|
||||||
|
"_requiredBy": [
|
||||||
|
"#USER",
|
||||||
|
"/"
|
||||||
|
],
|
||||||
|
"_resolved": "https://registry.npmjs.org/hashmap/-/hashmap-2.3.0.tgz",
|
||||||
|
"_shasum": "b13fb65da7c8ba5e3db8fc1b8c5ba1d0049daf22",
|
||||||
|
"_spec": "hashmap",
|
||||||
|
"_where": "C:\\Users\\jonio\\Documents\\Programmieren\\Miniportal\\Neu\\MiniportalAPI",
|
||||||
|
"author": {
|
||||||
|
"name": "Ariel Flesler",
|
||||||
|
"url": "https://github.com/flesler"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/flesler/hashmap/issues"
|
||||||
|
},
|
||||||
|
"bundleDependencies": false,
|
||||||
|
"dependencies": {},
|
||||||
|
"deprecated": false,
|
||||||
|
"description": "HashMap Class for JavaScript",
|
||||||
|
"devDependencies": {
|
||||||
|
"chai": "4.1.1",
|
||||||
|
"husky": "0.14.3",
|
||||||
|
"jshint": "2.9.5",
|
||||||
|
"mocha": "3.5.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "*"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/flesler/hashmap",
|
||||||
|
"keywords": [
|
||||||
|
"hashmap",
|
||||||
|
"map",
|
||||||
|
"object",
|
||||||
|
"array",
|
||||||
|
"associative",
|
||||||
|
"javascript",
|
||||||
|
"nodejs",
|
||||||
|
"node",
|
||||||
|
"browser"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "./hashmap.js",
|
||||||
|
"name": "hashmap",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/flesler/hashmap.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"precommit": "jshint hashmap.js",
|
||||||
|
"prepush": "npm run test",
|
||||||
|
"test": "mocha test/ --reporter dot"
|
||||||
|
},
|
||||||
|
"version": "2.3.0"
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
Copyright (c) 2009-2017 Jeremy Ashkenas, DocumentCloud and Investigative
|
||||||
|
Reporters & Editors
|
||||||
|
|
||||||
|
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.
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
__
|
||||||
|
/\ \ __
|
||||||
|
__ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____
|
||||||
|
/\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\
|
||||||
|
\ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\
|
||||||
|
\ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/
|
||||||
|
\/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/
|
||||||
|
\ \____/
|
||||||
|
\/___/
|
||||||
|
|
||||||
|
Underscore.js is a utility-belt library for JavaScript that provides
|
||||||
|
support for the usual functional suspects (each, map, reduce, filter...)
|
||||||
|
without extending any core JavaScript objects.
|
||||||
|
|
||||||
|
For Docs, License, Tests, and pre-packed downloads, see:
|
||||||
|
http://underscorejs.org
|
||||||
|
|
||||||
|
For support and questions, please use
|
||||||
|
[the gitter channel](https://gitter.im/jashkenas/underscore)
|
||||||
|
or [stackoverflow](http://stackoverflow.com/search?q=underscore.js)
|
||||||
|
|
||||||
|
Underscore is an open-sourced component of DocumentCloud:
|
||||||
|
https://github.com/documentcloud
|
||||||
|
|
||||||
|
Many thanks to our contributors:
|
||||||
|
https://github.com/jashkenas/underscore/contributors
|
||||||
|
|
||||||
|
This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
|
||||||
+82
@@ -0,0 +1,82 @@
|
|||||||
|
{
|
||||||
|
"_from": "underscore",
|
||||||
|
"_id": "underscore@1.9.0",
|
||||||
|
"_inBundle": false,
|
||||||
|
"_integrity": "sha512-4IV1DSSxC1QK48j9ONFK1MoIAKKkbE8i7u55w2R6IqBqbT7A/iG7aZBCR2Bi8piF0Uz+i/MG1aeqLwl/5vqF+A==",
|
||||||
|
"_location": "/underscore",
|
||||||
|
"_phantomChildren": {},
|
||||||
|
"_requested": {
|
||||||
|
"type": "tag",
|
||||||
|
"registry": true,
|
||||||
|
"raw": "underscore",
|
||||||
|
"name": "underscore",
|
||||||
|
"escapedName": "underscore",
|
||||||
|
"rawSpec": "",
|
||||||
|
"saveSpec": null,
|
||||||
|
"fetchSpec": "latest"
|
||||||
|
},
|
||||||
|
"_requiredBy": [
|
||||||
|
"#USER",
|
||||||
|
"/"
|
||||||
|
],
|
||||||
|
"_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.0.tgz",
|
||||||
|
"_shasum": "31dbb314cfcc88f169cd3692d9149d81a00a73e4",
|
||||||
|
"_spec": "underscore",
|
||||||
|
"_where": "C:\\Users\\jonio\\Documents\\Programmieren\\Miniportal\\Neu\\MiniportalAPI",
|
||||||
|
"author": {
|
||||||
|
"name": "Jeremy Ashkenas",
|
||||||
|
"email": "jeremy@documentcloud.org"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/jashkenas/underscore/issues"
|
||||||
|
},
|
||||||
|
"bundleDependencies": false,
|
||||||
|
"deprecated": false,
|
||||||
|
"description": "JavaScript's functional programming helper library.",
|
||||||
|
"devDependencies": {
|
||||||
|
"coveralls": "^2.11.2",
|
||||||
|
"docco": "*",
|
||||||
|
"eslint": "1.10.x",
|
||||||
|
"gzip-size-cli": "^1.0.0",
|
||||||
|
"karma": "^0.13.13",
|
||||||
|
"karma-qunit": "~2.0.1",
|
||||||
|
"nyc": "^2.1.3",
|
||||||
|
"pretty-bytes-cli": "^1.0.0",
|
||||||
|
"qunit": "^2.6.0",
|
||||||
|
"qunit-cli": "~0.2.0",
|
||||||
|
"uglify-js": "3.3.21"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"underscore.js",
|
||||||
|
"underscore-min.js",
|
||||||
|
"underscore-min.js.map"
|
||||||
|
],
|
||||||
|
"homepage": "http://underscorejs.org",
|
||||||
|
"keywords": [
|
||||||
|
"util",
|
||||||
|
"functional",
|
||||||
|
"server",
|
||||||
|
"client",
|
||||||
|
"browser"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "underscore.js",
|
||||||
|
"name": "underscore",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/jashkenas/underscore.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "npm run minify -- --source-map --source-map-url \" \" -o underscore-min.js",
|
||||||
|
"coverage": "nyc npm run test-node && nyc report",
|
||||||
|
"coveralls": "nyc npm run test-node && nyc report --reporter=text-lcov | coveralls",
|
||||||
|
"doc": "docco underscore.js",
|
||||||
|
"lint": "eslint underscore.js test/*.js",
|
||||||
|
"minify": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m",
|
||||||
|
"test": "npm run test-node && npm run lint",
|
||||||
|
"test-browser": "npm i karma-phantomjs-launcher && karma start",
|
||||||
|
"test-node": "qunit-cli test/*.js",
|
||||||
|
"weight": "npm run minify | gzip-size | pretty-bytes"
|
||||||
|
},
|
||||||
|
"version": "1.9.0"
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
// Underscore.js 1.9.0
|
||||||
|
// http://underscorejs.org
|
||||||
|
// (c) 2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||||
|
// Underscore may be freely distributed under the MIT license.
|
||||||
|
!function(){var n="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||this||{},r=n._,e=Array.prototype,o=Object.prototype,s="undefined"!=typeof Symbol?Symbol.prototype:null,u=e.push,c=e.slice,p=o.toString,i=o.hasOwnProperty,t=Array.isArray,a=Object.keys,l=Object.create,f=function(){},h=function(n){return n instanceof h?n:this instanceof h?void(this._wrapped=n):new h(n)};"undefined"==typeof exports||exports.nodeType?n._=h:("undefined"!=typeof module&&!module.nodeType&&module.exports&&(exports=module.exports=h),exports._=h),h.VERSION="1.9.0";var v,y=function(u,i,n){if(void 0===i)return u;switch(null==n?3:n){case 1:return function(n){return u.call(i,n)};case 3:return function(n,r,t){return u.call(i,n,r,t)};case 4:return function(n,r,t,e){return u.call(i,n,r,t,e)}}return function(){return u.apply(i,arguments)}},d=function(n,r,t){return h.iteratee!==v?h.iteratee(n,r):null==n?h.identity:h.isFunction(n)?y(n,r,t):h.isObject(n)&&!h.isArray(n)?h.matcher(n):h.property(n)};h.iteratee=v=function(n,r){return d(n,r,1/0)};var g=function(u,i){return i=null==i?u.length-1:+i,function(){for(var n=Math.max(arguments.length-i,0),r=Array(n),t=0;t<n;t++)r[t]=arguments[t+i];switch(i){case 0:return u.call(this,r);case 1:return u.call(this,arguments[0],r);case 2:return u.call(this,arguments[0],arguments[1],r)}var e=Array(i+1);for(t=0;t<i;t++)e[t]=arguments[t];return e[i]=r,u.apply(this,e)}},m=function(n){if(!h.isObject(n))return{};if(l)return l(n);f.prototype=n;var r=new f;return f.prototype=null,r},b=function(r){return function(n){return null==n?void 0:n[r]}},j=function(n,r){for(var t=r.length,e=0;e<t;e++){if(null==n)return;n=n[r[e]]}return t?n:void 0},x=Math.pow(2,53)-1,_=b("length"),A=function(n){var r=_(n);return"number"==typeof r&&0<=r&&r<=x};h.each=h.forEach=function(n,r,t){var e,u;if(r=y(r,t),A(n))for(e=0,u=n.length;e<u;e++)r(n[e],e,n);else{var i=h.keys(n);for(e=0,u=i.length;e<u;e++)r(n[i[e]],i[e],n)}return n},h.map=h.collect=function(n,r,t){r=d(r,t);for(var e=!A(n)&&h.keys(n),u=(e||n).length,i=Array(u),o=0;o<u;o++){var a=e?e[o]:o;i[o]=r(n[a],a,n)}return i};var w=function(c){return function(n,r,t,e){var u=3<=arguments.length;return function(n,r,t,e){var u=!A(n)&&h.keys(n),i=(u||n).length,o=0<c?0:i-1;for(e||(t=n[u?u[o]:o],o+=c);0<=o&&o<i;o+=c){var a=u?u[o]:o;t=r(t,n[a],a,n)}return t}(n,y(r,e,4),t,u)}};h.reduce=h.foldl=h.inject=w(1),h.reduceRight=h.foldr=w(-1),h.find=h.detect=function(n,r,t){var e=(A(n)?h.findIndex:h.findKey)(n,r,t);if(void 0!==e&&-1!==e)return n[e]},h.filter=h.select=function(n,e,r){var u=[];return e=d(e,r),h.each(n,function(n,r,t){e(n,r,t)&&u.push(n)}),u},h.reject=function(n,r,t){return h.filter(n,h.negate(d(r)),t)},h.every=h.all=function(n,r,t){r=d(r,t);for(var e=!A(n)&&h.keys(n),u=(e||n).length,i=0;i<u;i++){var o=e?e[i]:i;if(!r(n[o],o,n))return!1}return!0},h.some=h.any=function(n,r,t){r=d(r,t);for(var e=!A(n)&&h.keys(n),u=(e||n).length,i=0;i<u;i++){var o=e?e[i]:i;if(r(n[o],o,n))return!0}return!1},h.contains=h.includes=h.include=function(n,r,t,e){return A(n)||(n=h.values(n)),("number"!=typeof t||e)&&(t=0),0<=h.indexOf(n,r,t)},h.invoke=g(function(n,t,e){var u,i;return h.isFunction(t)?i=t:h.isArray(t)&&(u=t.slice(0,-1),t=t[t.length-1]),h.map(n,function(n){var r=i;if(!r){if(u&&u.length&&(n=j(n,u)),null==n)return;r=n[t]}return null==r?r:r.apply(n,e)})}),h.pluck=function(n,r){return h.map(n,h.property(r))},h.where=function(n,r){return h.filter(n,h.matcher(r))},h.findWhere=function(n,r){return h.find(n,h.matcher(r))},h.max=function(n,e,r){var t,u,i=-1/0,o=-1/0;if(null==e||"number"==typeof e&&"object"!=typeof n[0]&&null!=n)for(var a=0,c=(n=A(n)?n:h.values(n)).length;a<c;a++)null!=(t=n[a])&&i<t&&(i=t);else e=d(e,r),h.each(n,function(n,r,t){u=e(n,r,t),(o<u||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},h.min=function(n,e,r){var t,u,i=1/0,o=1/0;if(null==e||"number"==typeof e&&"object"!=typeof n[0]&&null!=n)for(var a=0,c=(n=A(n)?n:h.values(n)).length;a<c;a++)null!=(t=n[a])&&t<i&&(i=t);else e=d(e,r),h.each(n,function(n,r,t){((u=e(n,r,t))<o||u===1/0&&i===1/0)&&(i=n,o=u)});return i},h.shuffle=function(n){return h.sample(n,1/0)},h.sample=function(n,r,t){if(null==r||t)return A(n)||(n=h.values(n)),n[h.random(n.length-1)];var e=A(n)?h.clone(n):h.values(n),u=_(e);r=Math.max(Math.min(r,u),0);for(var i=u-1,o=0;o<r;o++){var a=h.random(o,i),c=e[o];e[o]=e[a],e[a]=c}return e.slice(0,r)},h.sortBy=function(n,e,r){var u=0;return e=d(e,r),h.pluck(h.map(n,function(n,r,t){return{value:n,index:u++,criteria:e(n,r,t)}}).sort(function(n,r){var t=n.criteria,e=r.criteria;if(t!==e){if(e<t||void 0===t)return 1;if(t<e||void 0===e)return-1}return n.index-r.index}),"value")};var O=function(o,r){return function(e,u,n){var i=r?[[],[]]:{};return u=d(u,n),h.each(e,function(n,r){var t=u(n,r,e);o(i,n,t)}),i}};h.groupBy=O(function(n,r,t){h.has(n,t)?n[t].push(r):n[t]=[r]}),h.indexBy=O(function(n,r,t){n[t]=r}),h.countBy=O(function(n,r,t){h.has(n,t)?n[t]++:n[t]=1});var k=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00Line truncated
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["underscore.js"],"names":["root","self","global","this","previousUnderscore","_","ArrayProto","Array","prototype","ObjProto","Object","SymbolProto","Symbol","push","slice","toString","hasOwnProperty","nativeIsArray","isArray","nativeKeys","keys","nativeCreate","create","Ctor","obj","_wrapped","exports","nodeType","module","VERSION","builtinIteratee","optimizeCb","func","context","argCount","value","call","index","collection","accumulator","apply","arguments","cb","iteratee","identity","isFunction","isObject","matcher","property","Infinity","restArguments","startIndex","length","Math","max","rest","args","baseCreate","result","shallowProperty","key","deepGet","path","i","MAX_ARRAY_INDEX","pow","getLength","isArrayLike","each","forEach","map","collect","results","currentKey","createReduce","dir","memo","initial","reducer","reduce","foldl","inject","reduceRight","foldr","find","detect","predicate","findIndex","findKey","filter","select","list","reject","negate","every","all","some","any","contains","includes","include","item","fromIndex","guard","values","indexOf","invoke","contextPath","method","pluck","where","attrs","findWhere","computed","lastComputed","v","min","shuffle","sample","n","random","clone","last","rand","temp","sortBy","criteria","sort","left","right","a","b","group","behavior","partition","groupBy","has","indexBy","countBy","reStrSymbol","toArray","isString","match","size","pass","first","head","take","array","tail","drop","compact","Boolean","flatten","input","shallow","strict","output","idx","isArguments","j","len","without","otherArrays","difference","uniq","unique","isSorted","isBoolean","seen","union","arrays","intersection","argsLength","unzip","zip","object","createPredicateIndexFinder","findLastIndex","sortedIndex","low","high","mid","floor","createIndexFinder","predicateFind","isNaN","lastIndexOf","range","start","stop","step","ceil","chunk","count","executeBound","sourceFunc","boundFunc","callingContext","bind","TypeError","bound","callArgs","concat","partial","boundArgs","placeholder","position","bindAll","Error","memoize","hasher","cache","address","delay","wait","setTimeout","defer","throttle","options","timeout","previous","later","leading","now","throttled","remaining","clearTimeout","trailing","cancel","debounce","immediate","debounced","callNow","wrap","wrapper","compose","after","times","before","once","hasEnumBug","propertyIsEnumerable","nonEnumerableProps","collectNonEnumProps","nonEnumIdx","constructor","proto","prop","allKeys","mapObject","pairs","invert","functions","methods","names","createAssigner","keysFunc","defaults","source","l","extend","extendOwn","assign","eq","deepEq","keyInObj","pick","omit","String","props","tap","interceptor","isMatch","aStack","bStack","type","className","valueOf","areArrays","aCtor","bCtor","pop","isEqual","isEmpty","isElement","name","nodelist","document","childNodes","Int8Array","isFinite","isSymbol","parseFloat","isNumber","isNull","isUndefined","noConflict","constant","noop","propertyOf","matches","accum","Date","getTime","escapeMap","&","<",">","\"","'","`","unescapeMap","createEscaper","escaper","join","testRegexp","RegExp","replaceRegexp","string","test","replace","escape","unescape","fallback","idCounter","uniqueId","prefix","id","templateSettings","evaluate","interpolate","noMatch","escapes","\\","\r","\n","
","
","escapeRegExp","escapeChar","template","text","settings","oldSettings","render","offset","variable","Function","e","data","argument","chain","instance","_chain","chainResult","mixin","toJSON","define","amd"],"mappings":";;;;CAKC,WAQC,IAAIA,EAAsB,iBAARC,MAAoBA,KAAKA,OAASA,MAAQA,MACjC,iBAAVC,QAAsBA,OAAOA,SAAWA,QAAUA,QACzDC,MACA,GAGNC,EAAqBJ,EAAKK,EAG1BC,EAAaC,MAAMC,UAAWC,EAAWC,OAAOF,UAChDG,EAAgC,oBAAXC,OAAyBA,OAAOJ,UAAY,KAGjEK,EAAOP,EAAWO,KAClBC,EAAQR,EAAWQ,MACnBC,EAAWN,EAASM,SACpBC,EAAiBP,EAASO,eAI1BC,EAAgBV,MAAMW,QACtBC,EAAaT,OAAOU,KACpBC,EAAeX,OAAOY,OAGtBC,EAAO,aAGPlB,EAAI,SAASmB,GACf,OAAIA,aAAenB,EAAUmB,EACvBrB,gBAAgBE,OACtBF,KAAKsB,SAAWD,GADiB,IAAInB,EAAEmB,IASnB,oBAAXE,SAA2BA,QAAQC,SAM5C3B,EAAKK,EAAIA,GALY,oBAAVuB,SAA0BA,OAAOD,UAAYC,OAAOF,UAC7DA,QAAUE,OAAOF,QAAUrB,GAE7BqB,QAAQrB,EAAIA,GAMdA,EAAEwB,QAAU,QAKZ,IAmBIC,EAnBAC,EAAa,SAASC,EAAMC,EAASC,GACvC,QAAgB,IAAZD,EAAoB,OAAOD,EAC/B,OAAoB,MAAZE,EAAmB,EAAIA,GAC7B,KAAK,EAAG,OAAO,SAASC,GACtB,OAAOH,EAAKI,KAAKH,EAASE,IAG5B,KAAK,EAAG,OAAO,SAASA,EAAOE,EAAOC,GACpC,OAAON,EAAKI,KAAKH,EAASE,EAAOE,EAAOC,IAE1C,KAAK,EAAG,OAAO,SAASC,EAAaJ,EAAOE,EAAOC,GACjD,OAAON,EAAKI,KAAKH,EAASM,EAAaJ,EAAOE,EAAOC,IAGzD,OAAO,WACL,OAAON,EAAKQ,MAAMP,EAASQ,aAS3BC,EAAK,SAASP,EAAOF,EAASC,GAChC,OAAI7B,EAAEsC,WAAab,EAAwBzB,EAAEsC,SAASR,EAAOF,GAChD,MAATE,EAAsB9B,EAAEuC,SACxBvC,EAAEwC,WAAWV,GAAeJ,EAAWI,EAAOF,EAASC,GACvD7B,EAAEyC,SAASX,KAAW9B,EAAEa,QAAQiB,GAAe9B,EAAE0C,QAAQZ,GACtD9B,EAAE2C,SAASb,IAMpB9B,EAAEsC,SAAWb,EAAkB,SAASK,EAAOF,GAC7C,OAAOS,EAAGP,EAAOF,EAASgB,EAAAA,IAQ5B,IAAIC,EAAgB,SAASlB,EAAMmB,GAEjC,OADAA,EAA2B,MAAdA,EAAqBnB,EAAKoB,OAAS,GAAKD,EAC9C,WAIL,IAHA,IAAIC,EAASC,KAAKCLine truncated
|
||||||
+1688
File diff suppressed because it is too large.
Load diff
Generated
+10
@@ -195,6 +195,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
||||||
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
|
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
|
||||||
},
|
},
|
||||||
|
"hashmap": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/hashmap/-/hashmap-2.3.0.tgz",
|
||||||
|
"integrity": "sha1-sT+2XafIul49uPwbjFuh0ASdryI="
|
||||||
|
},
|
||||||
"http-errors": {
|
"http-errors": {
|
||||||
"version": "1.6.2",
|
"version": "1.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz",
|
||||||
@@ -510,6 +515,11 @@
|
|||||||
"mime-types": "2.1.17"
|
"mime-types": "2.1.17"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"underscore": {
|
||||||
|
"version": "1.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.0.tgz",
|
||||||
|
"integrity": "sha512-4IV1DSSxC1QK48j9ONFK1MoIAKKkbE8i7u55w2R6IqBqbT7A/iG7aZBCR2Bi8piF0Uz+i/MG1aeqLwl/5vqF+A=="
|
||||||
|
},
|
||||||
"unpipe": {
|
"unpipe": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||||
|
|||||||
@@ -13,8 +13,10 @@
|
|||||||
"errorhandler": "^1.5.0",
|
"errorhandler": "^1.5.0",
|
||||||
"express": "^4.16.1",
|
"express": "^4.16.1",
|
||||||
"express-force-ssl": "^0.3.2",
|
"express-force-ssl": "^0.3.2",
|
||||||
|
"hashmap": "^2.3.0",
|
||||||
"mysql": "^2.15.0",
|
"mysql": "^2.15.0",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
|
"underscore": "^1.9.0",
|
||||||
"uuid": "^3.1.0"
|
"uuid": "^3.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user