@paralleldrive/react-feature-toggles
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -12,2 +12,6 @@ 'use strict'; | ||
var _curry = require('lodash/fp/curry'); | ||
var _curry2 = _interopRequireDefault(_curry); | ||
var _feature = require('./feature'); | ||
@@ -17,14 +21,10 @@ | ||
var configureFeature = exports.configureFeature = function configureFeature(inactiveComponent) { | ||
return function (name) { | ||
return function (activeComponent) { | ||
return function () { | ||
return _react2.default.createElement(_feature.Feature, { | ||
name: name, | ||
inactiveComponent: inactiveComponent, | ||
activeComponent: activeComponent | ||
}); | ||
}; | ||
}; | ||
var configureFeature = exports.configureFeature = (0, _curry2.default)(function (inactiveComponent, name, activeComponent) { | ||
return function () { | ||
return _react2.default.createElement(_feature.Feature, { | ||
name: name, | ||
inactiveComponent: inactiveComponent, | ||
activeComponent: activeComponent | ||
}); | ||
}; | ||
}; | ||
}); |
@@ -33,5 +33,5 @@ 'use strict'; | ||
(0, _riteway.describe)('configureFeature(inactiveComponent)(name)(activeComponent)', function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(should) { | ||
var _should, assert, ActiveComponent, InactiveComponent, ConfiguredFeature, features, $, _ActiveComponent, _InactiveComponent, _ConfiguredFeature, _features, _$; | ||
(0, _riteway.describe)('configureFeature()', function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(assert) { | ||
var ActiveComponent, InactiveComponent, ConfiguredFeature, features, $, _ActiveComponent, _InactiveComponent, _ConfiguredFeature, _features, _$; | ||
@@ -42,3 +42,2 @@ return regeneratorRuntime.wrap(function _callee$(_context) { | ||
case 0: | ||
_should = should(), assert = _should.assert; | ||
ActiveComponent = createTestComponent('active'); | ||
@@ -70,3 +69,3 @@ InactiveComponent = createTestComponent('inactive'); | ||
_InactiveComponent = createTestComponent('inactive'); | ||
_ConfiguredFeature = (0, _configureFeature.configureFeature)(_InactiveComponent)('game')(_ActiveComponent); | ||
_ConfiguredFeature = (0, _configureFeature.configureFeature)(_InactiveComponent, 'game', _ActiveComponent); | ||
_features = ['game', 'bar', 'baz']; | ||
@@ -94,3 +93,3 @@ _$ = _cheerio2.default.load(render(_react2.default.createElement( | ||
case 15: | ||
case 14: | ||
case 'end': | ||
@@ -97,0 +96,0 @@ return _context.stop(); |
@@ -28,4 +28,4 @@ 'use strict'; | ||
(0, _riteway.describe)('FeatureToggles()', function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(should) { | ||
var _should, assert, $, _$, features, _$2; | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(assert) { | ||
var $, _$, features, _$2; | ||
@@ -36,3 +36,2 @@ return regeneratorRuntime.wrap(function _callee$(_context) { | ||
case 0: | ||
_should = should(), assert = _should.assert; | ||
$ = _cheerio2.default.load(render(_react2.default.createElement( | ||
@@ -109,3 +108,3 @@ _featureToggles.FeatureToggles, | ||
case 8: | ||
case 7: | ||
case 'end': | ||
@@ -112,0 +111,0 @@ return _context.stop(); |
@@ -34,4 +34,4 @@ 'use strict'; | ||
(0, _riteway.describe)('Feature()', function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(should) { | ||
var _should, assert, ActiveComponent, InactiveComponent, features, $, _ActiveComponent, _InactiveComponent, _features, _$, _ActiveComponent2, _features2, _$2, _ActiveComponent3, _features3, _$3, _InactiveComponent2, _ActiveComponent4, _features4, _$4; | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(assert) { | ||
var ActiveComponent, InactiveComponent, features, $, _ActiveComponent, _InactiveComponent, _features, _$, _ActiveComponent2, _features2, _$2, _ActiveComponent3, _features3, _$3, _InactiveComponent2, _ActiveComponent4, _features4, _$4; | ||
@@ -42,3 +42,2 @@ return regeneratorRuntime.wrap(function _callee$(_context) { | ||
case 0: | ||
_should = should(), assert = _should.assert; | ||
ActiveComponent = createTestComponent('active'); | ||
@@ -159,3 +158,3 @@ InactiveComponent = createTestComponent('inactive'); | ||
case 27: | ||
case 26: | ||
case 'end': | ||
@@ -162,0 +161,0 @@ return _context.stop(); |
@@ -56,4 +56,4 @@ 'use strict'; | ||
(0, _riteway.describe)('withFeatureToggles()', function () { | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(should) { | ||
var _should, assert, Component, Page, $, _should2, _assert, _Component, features, _Page, _$, _should3, _assert2, _Component2, _features, _Page2, _$2, _Component3, _Page3, propCheck, _$3; | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(assert) { | ||
var Component, Page, $, _Component, features, _Page, _$, _Component2, _features, _Page2, _$2, _Component3, _Page3, propCheck, _$3; | ||
@@ -64,3 +64,2 @@ return regeneratorRuntime.wrap(function _callee$(_context) { | ||
case 0: | ||
_should = should(), assert = _should.assert; | ||
Component = createTestComponent(); | ||
@@ -77,3 +76,2 @@ Page = (0, _withFeatureToggles.withFeatureToggles)()(Component); | ||
}); | ||
_should2 = should(), _assert = _should2.assert; | ||
_Component = createTestComponent(); | ||
@@ -85,3 +83,3 @@ features = []; | ||
_assert({ | ||
assert({ | ||
given: 'empty features array', | ||
@@ -92,3 +90,2 @@ should: 'provide the correct features via context', | ||
}); | ||
_should3 = should(), _assert2 = _should3.assert; | ||
_Component2 = createTestComponent(); | ||
@@ -100,3 +97,3 @@ _features = ['foo', 'bar', 'baz']; | ||
_assert2({ | ||
assert({ | ||
given: 'features array', | ||
@@ -120,3 +117,3 @@ should: 'provide the correct features via context', | ||
case 22: | ||
case 19: | ||
case 'end': | ||
@@ -123,0 +120,0 @@ return _context.stop(); |
{ | ||
"name": "@paralleldrive/react-feature-toggles", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "React Feature Toggles", | ||
@@ -20,3 +20,3 @@ "main": "dist/index.js", | ||
"babel-cli": "6.26.0", | ||
"babel-eslint": "8.2.3", | ||
"babel-eslint": "10.0.1", | ||
"babel-polyfill": "6.26.0", | ||
@@ -29,15 +29,15 @@ "babel-preset-env": "1.7.0", | ||
"deep-freeze": "0.0.1", | ||
"eslint": "4.19.1", | ||
"eslint-config-prettier": "2.9.0", | ||
"eslint-plugin-react": "7.9.1", | ||
"husky": "0.14.3", | ||
"eslint": "5.13.0", | ||
"eslint-config-prettier": "4.0.0", | ||
"eslint-plugin-react": "7.12.4", | ||
"husky": "1.3.1", | ||
"pre-commit": "1.2.2", | ||
"prettier": "1.13.5", | ||
"pretty-quick": "1.6.0", | ||
"prettier": "1.16.4", | ||
"pretty-quick": "1.10.0", | ||
"prop-types": "15.6.2", | ||
"react": "16.4.1", | ||
"react-dom": "16.4.1", | ||
"riteway": "2.0.4", | ||
"tape": "4.9.1", | ||
"updtr": "2.0.0", | ||
"react": "16.8.1", | ||
"react-dom": "16.8.1", | ||
"riteway": "4.0.1", | ||
"tape": "4.9.2", | ||
"updtr": "3.1.0", | ||
"watch": "1.0.2" | ||
@@ -44,0 +44,0 @@ }, |
# React Feature Toggles | ||
[![Build Status](https://travis-ci.com/paralleldrive/react-feature-toggles.svg?token=Ba8H1FN3UT5CqqFhs2AM&branch=master)](https://travis-ci.com/paralleldrive/react-feature-toggles) | ||
[![Build Status](https://travis-ci.com/paralleldrive/react-feature-toggles.svg?token=Ba8H1FN3UT5CqqFhs2AM&branch=master)](https://travis-ci.com/paralleldrive/react-feature-toggles)[![Known Vulnerabilities](https://snyk.io/test/github/paralleldrive/react-feature-toggles/badge.svg?targetFile=package.json)](https://snyk.io/test/github/paralleldrive/react-feature-toggles?targetFile=package.json) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/paralleldrive/react-feature-toggles/badge.svg?targetFile=package.json)](https://snyk.io/test/github/paralleldrive/react-feature-toggles?targetFile=package.json) | ||
## Version 2 | ||
@@ -60,3 +58,3 @@ | ||
```js | ||
import { FeatureToggles } from '@paralleldrive/react*feature-toggles'; | ||
import { FeatureToggles } from '@paralleldrive/react-feature-toggles'; | ||
@@ -153,2 +151,4 @@ const features = ['foo', 'bar', 'baz', 'cat']; | ||
`configureFeature` is autocurried, so you can call it with one or more of its arguments to create a partial application of the function. In the following example, `featureOr404()` is a partial application of `configureFeature()`: | ||
```js | ||
@@ -160,3 +160,3 @@ import { FeatureToggles } from '@paralleldrive/react-feature-toggles'; | ||
const featureOr404 = configureFeature(NotFoundPage); | ||
const Chat = featureOr404('chat')(ChatPage); | ||
const Chat = featureOr404('chat', ChatPage); | ||
@@ -163,0 +163,0 @@ const features = ['foo', 'bar', 'chat']; |
@@ -19,5 +19,3 @@ import React from 'react'; | ||
describe('FeatureToggles and Feature', async should => { | ||
const { assert } = should(); | ||
describe('FeatureToggles and Feature', async assert => { | ||
{ | ||
@@ -76,5 +74,3 @@ const FooActive = createTestComponent('foo-active'); | ||
describe('FeatureToggles and configureFeature', async should => { | ||
const { assert } = should(); | ||
describe('FeatureToggles and configureFeature', async assert => { | ||
{ | ||
@@ -128,5 +124,3 @@ const FooActive = createTestComponent('foo-active'); | ||
describe('withFeatureToggles and configureFeature', async should => { | ||
const { assert } = should(); | ||
describe('withFeatureToggles and configureFeature', async assert => { | ||
{ | ||
@@ -133,0 +127,0 @@ const FooActive = createTestComponent('foo-active'); |
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
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
38975
23
747
1