Socket
Socket
Sign inDemoInstall

@karhoo/lib-feature-flags

Package Overview
Dependencies
6
Maintainers
5
Versions
127
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 20.1.0 to 20.1.1

14

dist/lib-feature-flags.cjs.development.js

@@ -480,3 +480,3 @@ 'use strict';

if (onChange === void 0) {
onChange = function onChange() {//do nothing
onChange = function onChange(_) {//do nothing
};

@@ -587,6 +587,6 @@ }

var _this$props = _this.props,
feature = _this$props.feature,
featureFlags = _this$props.featureFlags,
logger = _this$props.logger;
feature.listen(_this.onFeaturesChange);
feature.init().then(function () {
featureFlags.listen(_this.onFeaturesChange);
featureFlags.init().then(function () {
return _this.setState({

@@ -611,11 +611,11 @@ isInitialized: true

_this.disableFeature = function (name) {
return _this.props.feature.disable(name);
return _this.props.featureFlags.disable(name);
};
_this.enableFeature = function (name) {
return _this.props.feature.enable(name);
return _this.props.featureFlags.enable(name);
};
_this.isEnabled = function (name) {
return _this.props.feature.isEnabled(name);
return _this.props.featureFlags.isEnabled(name);
};

@@ -622,0 +622,0 @@

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("react"),r=(t=e)&&"object"==typeof t&&"default"in t?t.default:t;function n(){n=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new L(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=x(a,r);if(u){if(u===l)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var l={};function h(){}function p(){}function d(){}var v={};c(v,i,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(O([])));g&&g!==e&&r.call(g,i)&&(v=g);var m=d.prototype=h.prototype=Object.create(v);function b(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var c=f(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function F(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function O(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:j}}function j(){return{value:void 0,done:!0}}return p.prototype=d,c(m,"constructor",d),c(d,"constructor",p),p.displayName=c(d,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,c(t,u,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),c(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),c(m,u,"Generator"),c(m,i,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(F),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),F(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;F(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function o(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function u(t){o(a,n,i,u,c,"next",t)}function c(t){o(a,n,i,u,c,"throw",t)}u(void 0)}))}}function a(){return(a=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function u(t,e){return(u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var c={defaultValueForMissingKeys:!1},s=function(){function t(t,e){void 0===e&&(e=c),this.features={},this.config=t,this.defaultValueForMissingKeys=e.defaultValueForMissingKeys}var e=t.prototype;return e.init=function(){var t=i(n().mark((function t(){return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.config.fetch();case 2:return this.updateFeatures(t.sent),t.abrupt("return",this);case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.updateFeatures=function(t){void 0===t&&(t={}),this.features=a({},this.features,t),this.onChange&&this.onChange(this.features)},e.listen=function(t){void 0===t&&(t=function(){}),this.onChange=t,this.onChange(this.features)},e.toggle=function(t,e){var r;this.updateFeatures(((r={})[t]=e,r))},e.enable=function(t){var e;this.updateFeatures(((e={})[t]=!0,e))},e.disable=function(t){var e;this.updateFeatures(((e={})[t]=!1,e))},e.isEnabled=function(t){if(this.features.hasOwnProperty(t))return this.features[t];var e=this.config.getValue?this.config.getValue(t):null;return null===e?this.defaultValueForMissingKeys:e},t}(),f=function(){function t(t,e){this.config={},this.env=e,this.config=this.env?t[this.env]:{}}var e=t.prototype;return e.fetch=function(){return Promise.resolve(this.config)},e.getValue=function(t){return this.config.hasOwnProperty(t)?this.config[t]:null},t}(),l=function(){function t(t){this.config={},this.fetcher=t}var e=t.prototype;return e.fetch=function(){var t=this;try{return this.fetcher().then((function(e){return t.config=e})).catch((function(){return t.config}))}catch(t){return Promise.reject(this.config)}},e.getValue=function(t){return this.config&&this.config.hasOwnProperty(t)?this.config[t]:null},t}(),h=e.createContext({}),p=function(t){var e,n;function o(e){var r;return(r=t.call(this,e)||this).init=function(){var t=r.props,e=t.feature,n=t.logger;e.listen(r.onFeaturesChange),e.init().then((function(){return r.setState({isInitialized:!0})})).catch((function(t){n&&n.error(new Error("Feature flags init error: "+(t?t.message:""))),r.setState({requestIsFailed:!0})}))},r.onFeaturesChange=function(t){return r.setState({featureConfig:t})},r.disableFeature=function(t){return r.props.feature.disable(t)},r.enableFeature=function(t){return r.props.feature.enable(t)},r.isEnabled=function(t){return r.props.feature.isEnabled(t)},r.state={featureConfig:{},isInitialized:!1},window.Feature={disableFeature:r.disableFeature,enableFeature:r.enableFeature,isEnabled:r.isEnabled},r}n=t,(e=o).prototype=Object.create(n.prototype),e.prototype.constructor=e,u(e,n);var i=o.prototype;return i.componentDidMount=function(){this.init()},i.render=function(){var t=r.createElement(h.Provider,{value:{isEnabled:this.isEnabled}},this.props.children),e=this.state,n=this.props;return e.isInitialized?t:e.requestIsFailed?n.fallback||t:n.spinner},o}(e.Component);p.defaultProps={spinner:null,fallback:null};var d=function(t){var e=t.name,n=t.children,o=t.disabledElement;return r.createElement(h.Consumer,null,(function(t){var r=t.isEnabled;return(void 0===r?function(){return!1}:r)(e)?n:o}))};d.defaultProps={children:null,disabledElement:null},exports.Feature=d,exports.FeatureContext=h,exports.FeatureFlags=s,exports.FeatureProvider=p,exports.ObjectConfig=f,exports.RemoteConfig=l;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("react"),r=(t=e)&&"object"==typeof t&&"default"in t?t.default:t;function n(){n=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new L(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=x(a,r);if(u){if(u===l)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var l={};function h(){}function p(){}function d(){}var v={};c(v,i,(function(){return this}));var g=Object.getPrototypeOf,y=g&&g(g(O([])));y&&y!==e&&r.call(y,i)&&(v=y);var m=d.prototype=h.prototype=Object.create(v);function b(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var c=f(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function F(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function O(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:j}}function j(){return{value:void 0,done:!0}}return p.prototype=d,c(m,"constructor",d),c(d,"constructor",p),p.displayName=c(d,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,c(t,u,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),c(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),c(m,u,"Generator"),c(m,i,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(F),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),F(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;F(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function o(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function u(t){o(a,n,i,u,c,"next",t)}function c(t){o(a,n,i,u,c,"throw",t)}u(void 0)}))}}function a(){return(a=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function u(t,e){return(u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var c={defaultValueForMissingKeys:!1},s=function(){function t(t,e){void 0===e&&(e=c),this.features={},this.config=t,this.defaultValueForMissingKeys=e.defaultValueForMissingKeys}var e=t.prototype;return e.init=function(){var t=i(n().mark((function t(){return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.config.fetch();case 2:return this.updateFeatures(t.sent),t.abrupt("return",this);case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.updateFeatures=function(t){void 0===t&&(t={}),this.features=a({},this.features,t),this.onChange&&this.onChange(this.features)},e.listen=function(t){void 0===t&&(t=function(t){}),this.onChange=t,this.onChange(this.features)},e.toggle=function(t,e){var r;this.updateFeatures(((r={})[t]=e,r))},e.enable=function(t){var e;this.updateFeatures(((e={})[t]=!0,e))},e.disable=function(t){var e;this.updateFeatures(((e={})[t]=!1,e))},e.isEnabled=function(t){if(this.features.hasOwnProperty(t))return this.features[t];var e=this.config.getValue?this.config.getValue(t):null;return null===e?this.defaultValueForMissingKeys:e},t}(),f=function(){function t(t,e){this.config={},this.env=e,this.config=this.env?t[this.env]:{}}var e=t.prototype;return e.fetch=function(){return Promise.resolve(this.config)},e.getValue=function(t){return this.config.hasOwnProperty(t)?this.config[t]:null},t}(),l=function(){function t(t){this.config={},this.fetcher=t}var e=t.prototype;return e.fetch=function(){var t=this;try{return this.fetcher().then((function(e){return t.config=e})).catch((function(){return t.config}))}catch(t){return Promise.reject(this.config)}},e.getValue=function(t){return this.config&&this.config.hasOwnProperty(t)?this.config[t]:null},t}(),h=e.createContext({}),p=function(t){var e,n;function o(e){var r;return(r=t.call(this,e)||this).init=function(){var t=r.props,e=t.featureFlags,n=t.logger;e.listen(r.onFeaturesChange),e.init().then((function(){return r.setState({isInitialized:!0})})).catch((function(t){n&&n.error(new Error("Feature flags init error: "+(t?t.message:""))),r.setState({requestIsFailed:!0})}))},r.onFeaturesChange=function(t){return r.setState({featureConfig:t})},r.disableFeature=function(t){return r.props.featureFlags.disable(t)},r.enableFeature=function(t){return r.props.featureFlags.enable(t)},r.isEnabled=function(t){return r.props.featureFlags.isEnabled(t)},r.state={featureConfig:{},isInitialized:!1},window.Feature={disableFeature:r.disableFeature,enableFeature:r.enableFeature,isEnabled:r.isEnabled},r}n=t,(e=o).prototype=Object.create(n.prototype),e.prototype.constructor=e,u(e,n);var i=o.prototype;return i.componentDidMount=function(){this.init()},i.render=function(){var t=r.createElement(h.Provider,{value:{isEnabled:this.isEnabled}},this.props.children),e=this.state,n=this.props;return e.isInitialized?t:e.requestIsFailed?n.fallback||t:n.spinner},o}(e.Component);p.defaultProps={spinner:null,fallback:null};var d=function(t){var e=t.name,n=t.children,o=t.disabledElement;return r.createElement(h.Consumer,null,(function(t){var r=t.isEnabled;return(void 0===r?function(){return!1}:r)(e)?n:o}))};d.defaultProps={children:null,disabledElement:null},exports.Feature=d,exports.FeatureContext=h,exports.FeatureFlags=s,exports.FeatureProvider=p,exports.ObjectConfig=f,exports.RemoteConfig=l;
//# sourceMappingURL=lib-feature-flags.cjs.production.min.js.map

@@ -473,3 +473,3 @@ import React, { createContext, Component } from 'react';

if (onChange === void 0) {
onChange = function onChange() {//do nothing
onChange = function onChange(_) {//do nothing
};

@@ -580,6 +580,6 @@ }

var _this$props = _this.props,
feature = _this$props.feature,
featureFlags = _this$props.featureFlags,
logger = _this$props.logger;
feature.listen(_this.onFeaturesChange);
feature.init().then(function () {
featureFlags.listen(_this.onFeaturesChange);
featureFlags.init().then(function () {
return _this.setState({

@@ -604,11 +604,11 @@ isInitialized: true

_this.disableFeature = function (name) {
return _this.props.feature.disable(name);
return _this.props.featureFlags.disable(name);
};
_this.enableFeature = function (name) {
return _this.props.feature.enable(name);
return _this.props.featureFlags.enable(name);
};
_this.isEnabled = function (name) {
return _this.props.feature.isEnabled(name);
return _this.props.featureFlags.isEnabled(name);
};

@@ -615,0 +615,0 @@

@@ -40,3 +40,3 @@ import { Component } from 'react';

private updateFeatures;
listen(onChange?: () => void): void;
listen(onChange?: (features: Features) => void): void;
toggle(key: string, value: boolean): void;

@@ -86,9 +86,3 @@ enable(key: string): void;

children: ReactNode;
feature: {
disable(name: string): void;
enable(name: string): void;
isEnabled(name: string): boolean;
init: () => Promise<void>;
listen(onChange: Function): void;
};
featureFlags: FeatureFlags;
spinner?: ReactNode;

@@ -95,0 +89,0 @@ fallback?: ReactNode;

{
"name": "@karhoo/lib-feature-flags",
"version": "20.1.0",
"version": "20.1.1",
"description": "Feature flags 🚩 library for Karhoo web apps. It provides possibility to enable/disable certain feature per environment without redeployment 🙃",

@@ -39,3 +39,3 @@ "keywords": [

},
"gitHead": "ed62a0a4ecd74dd9da945f25d9af8d99f54129d4"
"gitHead": "0dba9305077a4cb8a3ae3364e387d3f2bf349143"
}

@@ -33,3 +33,3 @@ import { Features, Config, DefaultOptions } from './types'

public listen(
onChange: () => void = () => {
onChange: (features: Features) => void = _ => {
//do nothing

@@ -36,0 +36,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc