CARVIEW |
Select Language
HTTP/2 301
location: https://raw.githubusercontent.com/nbubna/store/master/src/store.measure.js
accept-ranges: bytes
age: 0
date: Mon, 21 Jul 2025 16:17:48 GMT
via: 1.1 varnish
x-served-by: cache-bom4741-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753114668.479066,VS0,VE295
vary: Accept-Encoding
x-fastly-request-id: 207f803d07ba4a863deeb7096c78bd77cef700be
content-length: 0
HTTP/2 200
cache-control: max-age=300
content-security-policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
content-type: text/plain; charset=utf-8
etag: W/"2bf5cefe8f3b25a3a6a2c405fc5ba2a4e5ffec440e6c3798942807d4dd360333"
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
x-frame-options: deny
x-xss-protection: 1; mode=block
x-github-request-id: 5151:A8220:156DB:31D11:687E682C
content-encoding: gzip
accept-ranges: bytes
date: Mon, 21 Jul 2025 16:17:49 GMT
via: 1.1 varnish
x-served-by: cache-bom4740-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753114669.842791,VS0,VE352
vary: Authorization,Accept-Encoding
access-control-allow-origin: *
cross-origin-resource-policy: cross-origin
x-fastly-request-id: deecc28c76364ad278d8b0cbf221b94f772d7a70
expires: Mon, 21 Jul 2025 16:22:49 GMT
source-age: 0
content-length: 774
/**
* Copyright (c) 2013 ESHA Research
* Dual licensed under the MIT and GPL licenses:
* https://www.opensource.org/licenses/mit-license.php
* https://www.gnu.org/licenses/gpl.html
*
* store.remainingSpace();// returns remainingSpace value (if browser supports it)
* store.charsUsed();// returns length of all data when stringified
* store.charsLeft([true]);// tests how many more chars we can fit (crash threat!)
* store.charsTotal([true]);// charsUsed + charsLeft, duh.
*
* TODO: byte/string conversions
*
* Status: ALPHA - changing API *and* crash threats :)
*/
;(function(store, _) {
function put(area, s) {
try {
area.setItem("__test__", s);
return true;
} catch (e) {}
}
_.fn('remainingSpace', function() {
return this._area.remainingSpace;
});
_.fn('charsUsed', function() {
return _.stringify(this.getAll()).length - 2;
});
_.fn('charsLeft', function(test) {
if (this.isFake()){ return; }
if (arguments.length === 0) {
test = window.confirm('Calling store.charsLeft() may crash some browsers!');
}
if (test) {
var s = 's ', add = s;
// grow add for speed
while (put(store._area, s)) {
s += add;
if (add.length < 50000) {
add = s;
}
}
// shrink add for accuracy
while (add.length > 2) {
s = s.substring(0, s.length - (add.length/2));
while (put(store._area, s)) {
s += add;
}
add = add.substring(add.length/2);
}
_.remove(store._area, "__test__");
return s.length + 8;
}
});
_.fn('charsTotal', function(test) {
return store.charsUsed() + store.charsLeft(test);
});
})(window.store, window.store._);