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

react-diffy

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-diffy - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

108

dist/react-diff.js

@@ -1,10 +0,34 @@

import React, { Component } from "react";
import PropTypes from "prop-types";
import jsdiff from "diff";
"use strict";
const fnMap = {
chars: jsdiff.diffChars,
words: jsdiff.diffWords,
sentences: jsdiff.diffSentences,
json: jsdiff.diffJson
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require("react");
var _react2 = _interopRequireDefault(_react);
var _propTypes = require("prop-types");
var _propTypes2 = _interopRequireDefault(_propTypes);
var _diff = require("diff");
var _diff2 = _interopRequireDefault(_diff);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var fnMap = {
chars: _diff2.default.diffChars,
words: _diff2.default.diffWords,
sentences: _diff2.default.diffSentences,
json: _diff2.default.diffJson
};

@@ -24,34 +48,46 @@

export default class Diff extends Component {
render() {
const diff = fnMap[this.props.type](this.props.inputA, this.props.inputB);
const result = diff.map((part, index) => {
if (part.added) {
return React.createElement(
"ins",
var Diff = function (_Component) {
_inherits(Diff, _Component);
function Diff() {
_classCallCheck(this, Diff);
return _possibleConstructorReturn(this, (Diff.__proto__ || Object.getPrototypeOf(Diff)).apply(this, arguments));
}
_createClass(Diff, [{
key: "render",
value: function render() {
var diff = fnMap[this.props.type](this.props.inputA, this.props.inputB);
var result = diff.map(function (part, index) {
if (part.added) {
return _react2.default.createElement(
"ins",
{ key: index },
part.value
);
}
if (part.removed) {
return _react2.default.createElement(
"del",
{ key: index },
part.value
);
}
return _react2.default.createElement(
"span",
{ key: index },
part.value
);
}
if (part.removed) {
return React.createElement(
"del",
{ key: index },
part.value
);
}
return React.createElement(
"span",
{ key: index },
part.value
);
});
return React.createElement(
this.props.elementType,
{ className: this.props.className },
result
);
}
}
});
return _react2.default.createElement(this.props.elementType, { className: this.props.className }, result);
}
}]);
return Diff;
}(_react.Component);
exports.default = Diff;
Diff.defaultProps = {

@@ -58,0 +94,0 @@ inputA: "",

{
"name": "react-diffy",
"version": "1.0.0",
"version": "1.1.0",
"description": "Output differences between inputs, ready for css styling",

@@ -38,4 +38,5 @@ "main": "dist/react-diff.js",

"babel-cli": "^6.26.0",
"babel-plugin-transform-react-jsx": "^6.24.1"
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-preset-env": "^1.6.1"
}
}
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