/
ux.min.js
5 lines (5 loc) · 1.44 KB
/
ux.min.js
1
2
3
4
5
/*!
* https://github.com/ryanve/ux
* @license 0BSD
*/
!function(a,b,c){"undefined"!=typeof module&&module.exports?module.exports=c(require):a[b]=c(function(b){return a[b]})}(this,"ux",function(a){function b(a){if("string"==typeof a)return a;if("number"==typeof a)return""+a;throw new TypeError}function c(a){return"string"==typeof a?a:o.encode(null==a?{}:a)}function d(a){return null==a?{}:o.decode(a)}function e(a){return function(c){var d=q();return arguments.length?d[b(c)]===a:t(d,function(b){return d[b]===a})}}function f(a){function c(d){var e=q(),f=e[d=b(d)]===a;e[d]=a,f||r(e),c.emit(d,d)}return c}function g(a){this[this.enabled(a)?"disable":"enable"](a),g.emit(a,a)}function h(a){var c=q();return arguments.length?"boolean"==typeof c[b(a)]:t(c,function(a){return"boolean"==typeof c[a]})}function i(a){if(!arguments.length)return void r(null);var c=q();if(!delete c[a=b(a)])throw new Error;r(c),i.emit(a,a)}var j,k=a("cargo"),l=a("energy"),m="ux@0.0",n="undefined"!=typeof location&&location,o=k[n.hostname?"local":"session"],p=o.stores!==!1,q=p?function(){var a=o.get(m);return a&&"object"==typeof(a=d(a))&&a||{}}:function(){return j||{}},r=p?function(a){if("object"!=typeof a)throw new TypeError;a?o.set(m,c(a)):o.remove(m)}:function(a){"object"==typeof a&&(j=a)},s=Object.keys,t=s?function(a,b,c){return s(a).filter(b,c)}:function(){return[]};return{enable:l.to(f(!0)),disable:l.to(f(!1)),toggle:l.to(g),forget:l.to(i),enabled:e(!0),disabled:e(!1),known:h}});