Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

es6-react-mixins

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-react-mixins - npm Package Compare versions

Comparing version 0.1.8 to 0.2.0

scripts/test

63

lib/mixin.js

@@ -8,2 +8,4 @@ /*

var _get = require('babel-runtime/helpers/get')['default'];
var _inherits = require('babel-runtime/helpers/inherits')['default'];

@@ -13,9 +15,9 @@

var _Object$defineProperty = require('babel-runtime/core-js/object/define-property')['default'];
var _Object$assign = require('babel-runtime/core-js/object/assign')['default'];
var _Object$keys = require('babel-runtime/core-js/object/keys')['default'];
var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default'];
_Object$defineProperty(exports, '__esModule', {
Object.defineProperty(exports, '__esModule', {
value: true

@@ -28,2 +30,5 @@ });

var REACT_PROPS = ['childContextTypes', 'contextTypes', 'defaultProps', 'propTypes'];
var REACT_LIFECYCLES = ['componentWillMount', 'componentDidMount', 'componentWillReceiveProps', 'componentWillUpdate', 'componentDidUpdate', 'componentWillUnmount', 'render'];
var noop = function noop() {

@@ -45,12 +50,10 @@ return null;

var NewClass = (function (_Base) {
_inherits(NewClass, _Base);
function NewClass() {
_classCallCheck(this, NewClass);
if (_Base != null) {
_Base.apply(this, arguments);
}
_get(Object.getPrototypeOf(NewClass.prototype), 'constructor', this).apply(this, arguments);
}
_inherits(NewClass, _Base);
return NewClass;

@@ -60,7 +63,6 @@ })(Base);

var clonedMixin = _Object$assign({}, mixin);
// These React properties are defined as ES7 class static properties
['childContextTypes', 'contextTypes', 'defaultProps', 'propTypes'].forEach(function (m) {
NewClass[m] = clonedMixin[m];
delete clonedMixin[m];
});
// move React props to NewClass's constructor
upgradeReactProps(NewClass, clonedMixin);
// merge React props defined as ES7 class static properties
mergeStaticProps(NewClass, clonedMixin);
_Object$assign(NewClass.prototype, clonedMixin);

@@ -78,12 +80,10 @@

var Base = (function (_React$Component) {
_inherits(Base, _React$Component);
function Base() {
_classCallCheck(this, Base);
if (_React$Component != null) {
_React$Component.apply(this, arguments);
}
_get(Object.getPrototypeOf(Base.prototype), 'constructor', this).apply(this, arguments);
}
_inherits(Base, _React$Component);
return Base;

@@ -95,3 +95,3 @@ })(_react2['default'].Component);

// No-ops so we need not check before calling super()
['componentWillMount', 'componentDidMount', 'componentWillReceiveProps', 'componentWillUpdate', 'componentDidUpdate', 'componentWillUnmount', 'render'].forEach(function (m) {
REACT_LIFECYCLES.forEach(function (m) {
return Base.prototype[m] = noop;

@@ -108,3 +108,24 @@ });

exports['default'] = mixin;
module.exports = exports['default'];
function upgradeReactProps(klass, mixin) {
var staticProps = REACT_PROPS.reduce(function (result, prop) {
klass[prop] = mixin[prop];
delete mixin[prop];
return result;
}, {});
return klass;
}
function mergeStaticProps(klass, clonedMixin) {
var superKlass = Object.getPrototypeOf(klass);
var mixin = clonedMixin || superKlass;
_Object$keys(mixin).forEach(function (m) {
if (typeof m !== 'function') {
klass[m] = _Object$assign(klass[m] || {}, mixin[m]);
}
});
return klass;
}
exports.mergeStaticProps = mergeStaticProps;
exports['default'] = mixin;
{
"name": "es6-react-mixins",
"version": "0.1.8",
"version": "0.2.0",
"description": "Augments ES6 classes with ES6 or traditional React mixins",

@@ -8,5 +8,5 @@ "author": "Angus Croll",

"scripts": {
"compile": "babel --optional runtime src --out-dir lib",
"compile": "babel --stage 0 --optional runtime src --out-dir lib",
"prepublish": "npm run compile",
"test": "./node_modules/karma/bin/karma start --single-run"
"test": "scripts/test"
},

@@ -25,17 +25,14 @@ "license": "MIT",

"devDependencies": {
"babel": "^5.5.8",
"babel-core": "^5.5.8",
"babel-loader": "^5.1.4",
"karma": "^0.12.31",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^0.1.8",
"karma-firefox-launcher": "^0.1.4",
"karma-mocha": "^0.1.10",
"karma-sourcemap-loader": "^0.3.4",
"karma-webpack": "^1.5.0",
"webpack": "^1.8.9"
"babel": "^5.8.23",
"babel-core": "^5.8.25",
"babel-loader": "^5.3.2",
"chai": "^3.3.0",
"jsdom": "^6.5.1",
"mocha": "^2.3.3",
"mocha-jsdom": "^1.0.0",
"webpack": "^1.12.2"
},
"dependencies": {
"babel-runtime": "^5.5.8",
"react": "^0.13.2"
"babel-runtime": "^5.8.25",
"react": "^0.13.3"
},

@@ -42,0 +39,0 @@ "bugs": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc