apps-script-db
Advanced tools
Comparing version 0.4.0 to 0.4.1
'use strict'; | ||
var AppsScriptDB = function AppsScriptDB(url, fetch) { | ||
if ( fetch === void 0 ) fetch = window.fetch; | ||
if ( fetch === void 0 ) fetch = window.fetch.bind(window); | ||
if (typeof url !== 'string' || typeof fetch !== 'function') { throw new TypeError('url should be string,fetch should be whatwg-fetch.'); } | ||
this.url = url; | ||
this.fetch = fetch; | ||
if (typeof url !== 'string' || typeof fetch !== 'function') { throw new TypeError('url should be string,fetch should be whatwg-fetch.'); } | ||
this.url = url; | ||
this.fetch = fetch; | ||
}; | ||
AppsScriptDB.prototype.handleResult = function handleResult (t) { | ||
return function (d) { | ||
if (d === 'error') { throw new Error(("Failed to " + t)); } | ||
return d; | ||
}; | ||
return function (d) { | ||
if (d === 'error') { throw new Error(("Failed to " + t)); } | ||
return d; | ||
}; | ||
}; | ||
AppsScriptDB.prototype._stringify = function _stringify (data) { | ||
return Object.keys(data).map(function (k) { return (k + "=" + (data[k])); }).join('&'); | ||
return Object.keys(data).map(function (k) { return (k + "=" + (data[k])); }).join('&'); | ||
}; | ||
AppsScriptDB.prototype._GET = function _GET (url, data) { | ||
return this.fetch((url + "?" + (this._stringify(data)))).then(function (r) { return r.text(); }); | ||
return this.fetch((url + "?" + (this._stringify(data)))).then(function (r) { return r.text(); }); | ||
}; | ||
AppsScriptDB.prototype._POST = function _POST (url, data) { | ||
return this.fetch(url, { | ||
method: 'POST', | ||
body: this._stringify(data), | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
} | ||
}).then(function (r) { return r.text(); }); | ||
return this.fetch(url, { | ||
method: 'POST', | ||
body: this._stringify(data), | ||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' } | ||
}).then(function (r) { return r.text(); }); | ||
}; | ||
AppsScriptDB.prototype.get = function get (key) { | ||
if ( key === void 0 ) key = '*'; | ||
if ( key === void 0 ) key = '*'; | ||
if (typeof key !== 'string') { throw new TypeError('key should be string.'); } | ||
return this._GET(this.url, { | ||
key: key | ||
}); | ||
if (typeof key !== 'string') { throw new TypeError('key should be string.'); } | ||
return this._GET(this.url, { key: key }); | ||
}; | ||
AppsScriptDB.prototype.set = function set (key, value) { | ||
if (typeof key !== 'string' || typeof value !== 'string') { throw new TypeError('key,value should be string.'); } | ||
return this._POST(this.url, { | ||
key: key, | ||
value: value | ||
}).then(this.handleResult('set')); | ||
if (typeof key !== 'string' || typeof value !== 'string') { throw new TypeError('key,value should be string.'); } | ||
return this._POST(this.url, { key: key, value: value }).then(this.handleResult('set')); | ||
}; | ||
AppsScriptDB.prototype.del = function del (del) { | ||
if ( del === void 0 ) del = '*'; | ||
if ( del === void 0 ) del = '*'; | ||
if (typeof del !== 'string') { throw new TypeError('key should be string.'); } | ||
return this._POST(this.url, { | ||
del: del | ||
}).then(this.handleResult('del')); | ||
if (typeof del !== 'string') { throw new TypeError('key should be string.'); } | ||
return this._POST(this.url, { del: del }).then(this.handleResult('del')); | ||
}; | ||
module.exports = AppsScriptDB; |
var AppsScriptDB = function AppsScriptDB(url, fetch) { | ||
if ( fetch === void 0 ) fetch = window.fetch; | ||
if ( fetch === void 0 ) fetch = window.fetch.bind(window); | ||
if (typeof url !== 'string' || typeof fetch !== 'function') { throw new TypeError('url should be string,fetch should be whatwg-fetch.'); } | ||
this.url = url; | ||
this.fetch = fetch; | ||
if (typeof url !== 'string' || typeof fetch !== 'function') { throw new TypeError('url should be string,fetch should be whatwg-fetch.'); } | ||
this.url = url; | ||
this.fetch = fetch; | ||
}; | ||
AppsScriptDB.prototype.handleResult = function handleResult (t) { | ||
return function (d) { | ||
if (d === 'error') { throw new Error(("Failed to " + t)); } | ||
return d; | ||
}; | ||
return function (d) { | ||
if (d === 'error') { throw new Error(("Failed to " + t)); } | ||
return d; | ||
}; | ||
}; | ||
AppsScriptDB.prototype._stringify = function _stringify (data) { | ||
return Object.keys(data).map(function (k) { return (k + "=" + (data[k])); }).join('&'); | ||
return Object.keys(data).map(function (k) { return (k + "=" + (data[k])); }).join('&'); | ||
}; | ||
AppsScriptDB.prototype._GET = function _GET (url, data) { | ||
return this.fetch((url + "?" + (this._stringify(data)))).then(function (r) { return r.text(); }); | ||
return this.fetch((url + "?" + (this._stringify(data)))).then(function (r) { return r.text(); }); | ||
}; | ||
AppsScriptDB.prototype._POST = function _POST (url, data) { | ||
return this.fetch(url, { | ||
method: 'POST', | ||
body: this._stringify(data), | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
} | ||
}).then(function (r) { return r.text(); }); | ||
return this.fetch(url, { | ||
method: 'POST', | ||
body: this._stringify(data), | ||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' } | ||
}).then(function (r) { return r.text(); }); | ||
}; | ||
AppsScriptDB.prototype.get = function get (key) { | ||
if ( key === void 0 ) key = '*'; | ||
if ( key === void 0 ) key = '*'; | ||
if (typeof key !== 'string') { throw new TypeError('key should be string.'); } | ||
return this._GET(this.url, { | ||
key: key | ||
}); | ||
if (typeof key !== 'string') { throw new TypeError('key should be string.'); } | ||
return this._GET(this.url, { key: key }); | ||
}; | ||
AppsScriptDB.prototype.set = function set (key, value) { | ||
if (typeof key !== 'string' || typeof value !== 'string') { throw new TypeError('key,value should be string.'); } | ||
return this._POST(this.url, { | ||
key: key, | ||
value: value | ||
}).then(this.handleResult('set')); | ||
if (typeof key !== 'string' || typeof value !== 'string') { throw new TypeError('key,value should be string.'); } | ||
return this._POST(this.url, { key: key, value: value }).then(this.handleResult('set')); | ||
}; | ||
AppsScriptDB.prototype.del = function del (del) { | ||
if ( del === void 0 ) del = '*'; | ||
if ( del === void 0 ) del = '*'; | ||
if (typeof del !== 'string') { throw new TypeError('key should be string.'); } | ||
return this._POST(this.url, { | ||
del: del | ||
}).then(this.handleResult('del')); | ||
if (typeof del !== 'string') { throw new TypeError('key should be string.'); } | ||
return this._POST(this.url, { del: del }).then(this.handleResult('del')); | ||
}; | ||
export default AppsScriptDB; |
@@ -7,63 +7,47 @@ (function (global, factory) { | ||
var AppsScriptDB = function AppsScriptDB(url, fetch) { | ||
if ( fetch === void 0 ) fetch = window.fetch; | ||
var AppsScriptDB = function AppsScriptDB(url, fetch) { | ||
if ( fetch === void 0 ) fetch = window.fetch.bind(window); | ||
if (typeof url !== 'string' || typeof fetch !== 'function') { throw new TypeError('url should be string,fetch should be whatwg-fetch.'); } | ||
this.url = url; | ||
this.fetch = fetch; | ||
if (typeof url !== 'string' || typeof fetch !== 'function') { throw new TypeError('url should be string,fetch should be whatwg-fetch.'); } | ||
this.url = url; | ||
this.fetch = fetch; | ||
}; | ||
AppsScriptDB.prototype.handleResult = function handleResult (t) { | ||
return function (d) { | ||
if (d === 'error') { throw new Error(("Failed to " + t)); } | ||
return d; | ||
}; | ||
}; | ||
AppsScriptDB.prototype._stringify = function _stringify (data) { | ||
return Object.keys(data).map(function (k) { return (k + "=" + (data[k])); }).join('&'); | ||
}; | ||
AppsScriptDB.prototype._GET = function _GET (url, data) { | ||
return this.fetch((url + "?" + (this._stringify(data)))).then(function (r) { return r.text(); }); | ||
}; | ||
AppsScriptDB.prototype._POST = function _POST (url, data) { | ||
return this.fetch(url, { | ||
method: 'POST', | ||
body: this._stringify(data), | ||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' } | ||
}).then(function (r) { return r.text(); }); | ||
}; | ||
AppsScriptDB.prototype.get = function get (key) { | ||
if ( key === void 0 ) key = '*'; | ||
AppsScriptDB.prototype.handleResult = function handleResult (t) { | ||
return function (d) { | ||
if (d === 'error') { throw new Error(("Failed to " + t)); } | ||
return d; | ||
}; | ||
}; | ||
if (typeof key !== 'string') { throw new TypeError('key should be string.'); } | ||
return this._GET(this.url, { key: key }); | ||
}; | ||
AppsScriptDB.prototype.set = function set (key, value) { | ||
if (typeof key !== 'string' || typeof value !== 'string') { throw new TypeError('key,value should be string.'); } | ||
return this._POST(this.url, { key: key, value: value }).then(this.handleResult('set')); | ||
}; | ||
AppsScriptDB.prototype.del = function del (del) { | ||
if ( del === void 0 ) del = '*'; | ||
AppsScriptDB.prototype._stringify = function _stringify (data) { | ||
return Object.keys(data).map(function (k) { return (k + "=" + (data[k])); }).join('&'); | ||
}; | ||
if (typeof del !== 'string') { throw new TypeError('key should be string.'); } | ||
return this._POST(this.url, { del: del }).then(this.handleResult('del')); | ||
}; | ||
AppsScriptDB.prototype._GET = function _GET (url, data) { | ||
return this.fetch((url + "?" + (this._stringify(data)))).then(function (r) { return r.text(); }); | ||
}; | ||
return AppsScriptDB; | ||
AppsScriptDB.prototype._POST = function _POST (url, data) { | ||
return this.fetch(url, { | ||
method: 'POST', | ||
body: this._stringify(data), | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
} | ||
}).then(function (r) { return r.text(); }); | ||
}; | ||
AppsScriptDB.prototype.get = function get (key) { | ||
if ( key === void 0 ) key = '*'; | ||
if (typeof key !== 'string') { throw new TypeError('key should be string.'); } | ||
return this._GET(this.url, { | ||
key: key | ||
}); | ||
}; | ||
AppsScriptDB.prototype.set = function set (key, value) { | ||
if (typeof key !== 'string' || typeof value !== 'string') { throw new TypeError('key,value should be string.'); } | ||
return this._POST(this.url, { | ||
key: key, | ||
value: value | ||
}).then(this.handleResult('set')); | ||
}; | ||
AppsScriptDB.prototype.del = function del (del) { | ||
if ( del === void 0 ) del = '*'; | ||
if (typeof del !== 'string') { throw new TypeError('key should be string.'); } | ||
return this._POST(this.url, { | ||
del: del | ||
}).then(this.handleResult('del')); | ||
}; | ||
return AppsScriptDB; | ||
}))); |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ADB=e()}(this,function(){"use strict";var t=function(t,e){if(void 0===e&&(e=window.fetch),"string"!=typeof t||"function"!=typeof e)throw new TypeError("url should be string,fetch should be whatwg-fetch.");this.url=t,this.fetch=e};return t.prototype.handleResult=function(t){return function(e){if("error"===e)throw new Error("Failed to "+t);return e}},t.prototype._stringify=function(t){return Object.keys(t).map(function(e){return e+"="+t[e]}).join("&")},t.prototype._GET=function(t,e){return this.fetch(t+"?"+this._stringify(e)).then(function(t){return t.text()})},t.prototype._POST=function(t,e){return this.fetch(t,{method:"POST",body:this._stringify(e),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(t){return t.text()})},t.prototype.get=function(t){if(void 0===t&&(t="*"),"string"!=typeof t)throw new TypeError("key should be string.");return this._GET(this.url,{key:t})},t.prototype.set=function(t,e){if("string"!=typeof t||"string"!=typeof e)throw new TypeError("key,value should be string.");return this._POST(this.url,{key:t,value:e}).then(this.handleResult("set"))},t.prototype.del=function(t){if(void 0===t&&(t="*"),"string"!=typeof t)throw new TypeError("key should be string.");return this._POST(this.url,{del:t}).then(this.handleResult("del"))},t}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ADB=e()}(this,function(){"use strict";var t=function(t,e){if(void 0===e&&(e=window.fetch.bind(window)),"string"!=typeof t||"function"!=typeof e)throw new TypeError("url should be string,fetch should be whatwg-fetch.");this.url=t,this.fetch=e};return t.prototype.handleResult=function(t){return function(e){if("error"===e)throw new Error("Failed to "+t);return e}},t.prototype._stringify=function(t){return Object.keys(t).map(function(e){return e+"="+t[e]}).join("&")},t.prototype._GET=function(t,e){return this.fetch(t+"?"+this._stringify(e)).then(function(t){return t.text()})},t.prototype._POST=function(t,e){return this.fetch(t,{method:"POST",body:this._stringify(e),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(t){return t.text()})},t.prototype.get=function(t){if(void 0===t&&(t="*"),"string"!=typeof t)throw new TypeError("key should be string.");return this._GET(this.url,{key:t})},t.prototype.set=function(t,e){if("string"!=typeof t||"string"!=typeof e)throw new TypeError("key,value should be string.");return this._POST(this.url,{key:t,value:e}).then(this.handleResult("set"))},t.prototype.del=function(t){if(void 0===t&&(t="*"),"string"!=typeof t)throw new TypeError("key should be string.");return this._POST(this.url,{del:t}).then(this.handleResult("del"))},t}); | ||
//# sourceMappingURL=apps-script-db.min.js.map |
{ | ||
"name": "apps-script-db", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"main": "dist/apps-script-db.cjs.js", | ||
@@ -5,0 +5,0 @@ "browser": "dist/apps-script-db.min.js", |
export default class AppsScriptDB { | ||
constructor(url, fetch = window.fetch) { | ||
constructor(url, fetch = window.fetch.bind(window)) { | ||
if (typeof url !== 'string' || typeof fetch !== 'function') | ||
@@ -4,0 +4,0 @@ throw new TypeError('url should be string,fetch should be whatwg-fetch.') |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12
121026
224