single quotes to double quotes

This commit is contained in:
Geoff Doty 2018-05-06 18:29:13 -04:00
parent 37f7cf0fe1
commit 59c6cc167d
3 changed files with 8 additions and 9 deletions

6
dist/record.js vendored
View File

@ -1,4 +1,4 @@
/*! Record.js v0.6.0 | MIT | https://github.com/n2geoff/record.js */ /*! Record.js v0.6.1 | MIT | https://github.com/n2geoff/record.js */
(function (root, factory) { (function (root, factory) {
"use strict"; "use strict";
if (typeof module === "object" && module.exports) { if (typeof module === "object" && module.exports) {
@ -128,13 +128,13 @@
dump() { dump() {
function download(filename, content) { function download(filename, content) {
let a = document.createElement("a"); let a = document.createElement("a");
let file = new Blob([content], {type: 'text/plain'}); let file = new Blob([content], {type: "text/plain"});
a.href = URL.createObjectURL(file); a.href = URL.createObjectURL(file);
a.download = filename; a.download = filename;
a.click(); a.click();
} }
download(`${this.store || 'data'}.json`, JSON.stringify(this._load(), null, 4)); download(`${this.store || "data"}.json`, JSON.stringify(this._load(), null, 4));
} }
} }

4
dist/record.min.js vendored
View File

@ -1,2 +1,2 @@
/*! Record.js v0.6.0 | 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))}}}); !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))}}});

View File

@ -1,4 +1,4 @@
/*! Record.js v0.6.0 | MIT | https://github.com/n2geoff/record.js */ /*! Record.js v0.6.1 | MIT | https://github.com/n2geoff/record.js */
(function (root, factory) { (function (root, factory) {
"use strict"; "use strict";
if (typeof module === "object" && module.exports) { if (typeof module === "object" && module.exports) {
@ -207,7 +207,6 @@
this._save(); this._save();
} }
// save to localstorage
/** /**
* save a record to storage if available * save a record to storage if available
* *
@ -245,13 +244,13 @@
dump() { dump() {
function download(filename, content) { function download(filename, content) {
let a = document.createElement("a"); let a = document.createElement("a");
let file = new Blob([content], {type: 'text/plain'}); let file = new Blob([content], {type: "text/plain"});
a.href = URL.createObjectURL(file); a.href = URL.createObjectURL(file);
a.download = filename; a.download = filename;
a.click(); a.click();
} }
download(`${this.store || 'data'}.json`, JSON.stringify(this._load(), null, 4)); download(`${this.store || "data"}.json`, JSON.stringify(this._load(), null, 4));
} }
} }