New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-jax

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-jax - npm Package Compare versions

Comparing version 0.3.0 to 1.0.0

41

lib/index.js

@@ -6,3 +6,2 @@ 'use strict';

});
exports.jax = exports.jaxDefaults = undefined;

@@ -29,4 +28,2 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -38,25 +35,14 @@

// overrideable defaults for the package
var jaxDefaults = exports.jaxDefaults = {
client: null,
methods: ['get', 'post', 'del', 'put'],
pendingKey: 'pending',
abortKey: 'abort',
endEvents: ['end', 'abort', 'error']
};
exports.default = function () {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
client = _ref.client,
_ref$endEvents = _ref.endEvents,
endEvents = _ref$endEvents === undefined ? ['end', 'abort', 'error'] : _ref$endEvents,
_ref$methods = _ref.methods,
methods = _ref$methods === undefined ? ['get', 'post', 'del', 'put'] : _ref$methods,
_ref$abortKey = _ref.abortKey,
abortKey = _ref$abortKey === undefined ? 'abort' : _ref$abortKey,
_ref$pendingKey = _ref.pendingKey,
pendingKey = _ref$pendingKey === undefined ? 'pending' : _ref$pendingKey;
// the decorator
var jax = exports.jax = function jax() {
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var _ref$client = _ref.client;
var client = _ref$client === undefined ? jaxDefaults.client : _ref$client;
var _ref$methods = _ref.methods;
var methods = _ref$methods === undefined ? jaxDefaults.methods : _ref$methods;
var _ref$abortKey = _ref.abortKey;
var abortKey = _ref$abortKey === undefined ? jaxDefaults.abortKey : _ref$abortKey;
var _ref$pendingKey = _ref.pendingKey;
var pendingKey = _ref$pendingKey === undefined ? jaxDefaults.pendingKey : _ref$pendingKey;
var _ref$endEvents = _ref.endEvents;
var endEvents = _ref$endEvents === undefined ? jaxDefaults.endEvents : _ref$endEvents;
return function (OriginalComponent) {

@@ -157,5 +143,6 @@ if (!OriginalComponent) throw new Error('No component to wrap.');

value: function render() {
var _extends2;
var props = _extends({}, this.props, this.methods);
var props = _extends({}, this.props, this.methods, (_extends2 = {}, _defineProperty(_extends2, abortKey, this.abort), _defineProperty(_extends2, pendingKey, this.state.pending), _extends2));
if (abortKey) props[abortKey] = this.abort;
if (pendingKey) props[pendingKey] = this.state.pending;

@@ -162,0 +149,0 @@ return (0, _react.createElement)(OriginalComponent, props);

{
"name": "react-jax",
"version": "0.3.0",
"version": "1.0.0",
"description": "A tiny decorator to manage AJAX requests in React components.",

@@ -32,3 +32,3 @@ "main": "lib/index.js",

"dependencies": {
"hoist-non-react-statics": "^1.2.0",
"hoist-non-react-statics": "^2.0.0",
"lodash": "^4.15.0",

@@ -51,8 +51,9 @@ "react-display-name": "^0.2.0"

"mocha": "^2.3.4",
"react": "^0.14.7",
"react-addons-test-utils": "^0.14.7",
"react": "^15.6.1",
"react-addons-test-utils": "^15.6.0",
"react-dom": "^15.6.1",
"sinon": "^1.17.5",
"sinon-chai": "^2.8.0",
"superagent": "^1.8.0"
"superagent": "^3.5.2"
}
}

@@ -14,11 +14,7 @@ # react-jax [![Build Status](https://travis-ci.org/azuqua/react-jax.svg?branch=master)](https://travis-ci.org/azuqua/react-jax)

import React from 'react';
import { jax, jaxDefaults } from 'react-jax';
import jax from 'react-jax';
import superagent from 'superagent';
/* set global defaults */
jaxDefaults.client = superagent; // IMPORTANT
jaxDefaults.pendingKey = 'loading';
/* overwrite global options for a specific component */
@jax({ // same as defaults
@jax({
client: superagent, // only required option
methods: ['get', 'post', 'del', 'put'],

@@ -65,4 +61,3 @@ pendingKey: 'pending',

These options can be passed to the `jax()` function. Or be set on the
exported `jaxDefaults` object.
These options are passed to the `jax()` function.

@@ -80,3 +75,3 @@ ##### `client` __required__

#### `endEvents` defaults to `['end', 'abort']`
#### `endEvents` defaults to `['end', 'abort', 'error']`
Events emitted by the clients request object than indicate it should be

@@ -83,0 +78,0 @@ cleaned up.

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