updated deps
This commit is contained in:
parent
0c11b4af7f
commit
886fca439b
|
@ -1,2 +1,2 @@
|
|||
/*! Record.js v0.6.1 | MIT | https://github.com/n2geoff/record.js */
|
||||
/*! Record.js v0.6.1 | MIT | https://github.com/n2geoff/record.js */
|
||||
!function(t,e){"use strict";"object"==typeof module&&module.exports?module.exports=e(t.Record):t.Record=e(t.Record)}(this,function(){"use strict";return class{constructor(t){if(this.store=(t||{}).store,this.debug=(t||{}).debug||!1,this.records=[],this.store&&localStorage){this._log("Initializing localStorage for "+this.store);let t=this._load()||[];this.records=[...t]}}_log(){this.debug&&console.log(...arguments)}add(t){if(Array.isArray(t)){let e=[];return t.forEach(()=>{t.id||(t.id=Math.random().toString(36).substr(2,9)),this.records.push(t),this.entries.push(t)}),this._save(),e}return t.id||(t.id=Math.random().toString(36).substr(2,9)),this.records.push(t),this._save(),t}find(t){if(!t)return this.records;if("string"==typeof t||"number"==typeof t)return this.records.filter(e=>e.id===t);let e=Object.keys(t);return this.records.filter(r=>-1!==e.indexOf("id")?r.id===t.id:e.every(e=>r[e]===t[e]))}remove(t){if(!t||Array.isArray(t))return this._log(console.error("remove() accepts a single object")),[];let e=this.find(t);return e.forEach(t=>{this.records.splice(this.records.indexOf(t),1)}),this._save(),e}clear(){this.records=[],this._save()}_save(){this.store&&localStorage&&localStorage.setItem(this.store,JSON.stringify(this.records))}_load(){if(this.store&&localStorage)return JSON.parse(localStorage.getItem(this.store))||[]}dump(){!function(t,e){let r=document.createElement("a"),s=new Blob([e],{type:"text/plain"});r.href=URL.createObjectURL(s),r.download=t,r.click()}(`${this.store||"data"}.json`,JSON.stringify(this._load(),null,4))}}});
|
|
@ -3,8 +3,8 @@ const minify = require('gulp-minify');
|
|||
const strip = require("gulp-strip-comments");
|
||||
|
||||
gulp.task("default", function() {
|
||||
gulp.src("./src/record.js")
|
||||
return gulp.src("./src/record.js")
|
||||
.pipe(strip({safe: true}))
|
||||
.pipe(minify({ext: {min: ".min.js"}}))
|
||||
.pipe(gulp.dest("dist"))
|
||||
.pipe(gulp.dest("dist"));
|
||||
});
|
File diff suppressed because it is too large
Load Diff
|
@ -27,10 +27,10 @@
|
|||
"author": "Geoff Doty",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-minify": "^2.1.0",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-minify": "^3.1.0",
|
||||
"gulp-strip-comments": "^2.5.2",
|
||||
"jshint": "^2.9.5",
|
||||
"tape": "^4.9.0"
|
||||
"jshint": "^2.9.7",
|
||||
"tape": "^4.9.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,18 +11,18 @@ test("Record.js", function(t) {
|
|||
t.ok(pets, "new collection should have been created");
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
t.test("should add 3 records one-by-one", function(t) {
|
||||
t.ok(pets.add, "add method exists");
|
||||
|
||||
|
||||
let plato = pets.add({"name": "plato", "type": "dog"});
|
||||
let socrates = pets.add({"id": "1", "name": "socrates", "type": "dog"});
|
||||
let hypatia = pets.add({"name": "hypatia", "type": "cat"});
|
||||
|
||||
|
||||
t.equal(plato.name, "plato", "plato should have been added");
|
||||
t.equal(socrates.name, "socrates", "socrates should have been added");
|
||||
t.equal(hypatia.name, "hypatia", "hypatia should have been added");
|
||||
|
||||
|
||||
t.ok(plato.id, "platos record id should be auto-generated");
|
||||
t.equal(socrates.id, "1","socrates record id should not be auto-generated");
|
||||
|
||||
|
@ -49,7 +49,7 @@ test("Record.js", function(t) {
|
|||
t.equal(hypatia[0].name, "hypatia", "hypatia should be removed");
|
||||
|
||||
t.equal(pets.find().length, 2, "yes, hypatia has left the building");
|
||||
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue