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

react-immutable-proptypes

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-immutable-proptypes - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

2

coverage/coverage.json

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

{"/Users/jtburnett/Sites/react-immutable-proptypes/babel.js":{"path":"/Users/jtburnett/Sites/react-immutable-proptypes/babel.js","s":{"1":1},"b":{},"f":{},"fnMap":{},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":4,"column":3}}},"branchMap":{}},"/Users/jtburnett/Sites/react-immutable-proptypes/src/ImmutablePropTypes.js":{"path":"/Users/jtburnett/Sites/react-immutable-proptypes/src/ImmutablePropTypes.js","s":{"1":1,"2":1,"3":1,"4":1,"5":6,"6":6,"7":1,"8":5,"9":0,"10":5,"11":1,"12":1,"13":20,"14":20,"15":4,"16":4,"17":2,"18":16,"19":19,"20":19,"21":19,"22":1,"23":1,"24":14,"25":14,"26":4,"27":4,"28":4,"29":10,"30":10,"31":19,"32":19,"33":2,"34":18,"35":1,"36":1,"37":2,"38":2,"39":2,"40":0,"41":0,"42":2,"43":2,"44":2,"45":0,"46":2,"47":2,"48":2,"49":0,"50":1,"51":1},"b":{"1":[1,5],"2":[0,5],"3":[20,0],"4":[4,16],"5":[2,2],"6":[4,10],"7":[2,17],"8":[0,2],"9":[0,2],"10":[0,2]},"f":{"1":6,"2":19,"3":20,"4":18,"5":14,"6":1,"7":2},"fnMap":{"1":{"name":"getPropType","line":18,"loc":{"start":{"line":18,"column":0},"end":{"line":18,"column":32}}},"2":{"name":"createChainableTypeChecker","line":32,"loc":{"start":{"line":32,"column":0},"end":{"line":32,"column":46}}},"3":{"name":"checkType","line":33,"loc":{"start":{"line":33,"column":2},"end":{"line":33,"column":75}}},"4":{"name":"createListOfTypeChecker","line":51,"loc":{"start":{"line":51,"column":0},"end":{"line":51,"column":46}}},"5":{"name":"validate","line":52,"loc":{"start":{"line":52,"column":2},"end":{"line":52,"column":62}}},"6":{"name":"createShapeTypeChecker","line":71,"loc":{"start":{"line":71,"column":0},"end":{"line":71,"column":44}}},"7":{"name":"validate","line":72,"loc":{"start":{"line":72,"column":2},"end":{"line":72,"column":62}}}},"statementMap":{"1":{"start":{"line":9,"column":0},"end":{"line":9,"column":37}},"2":{"start":{"line":11,"column":0},"end":{"line":11,"column":32}},"3":{"start":{"line":13,"column":0},"end":{"line":16,"column":2}},"4":{"start":{"line":18,"column":0},"end":{"line":30,"column":1}},"5":{"start":{"line":19,"column":2},"end":{"line":19,"column":34}},"6":{"start":{"line":20,"column":2},"end":{"line":22,"column":3}},"7":{"start":{"line":21,"column":4},"end":{"line":21,"column":19}},"8":{"start":{"line":23,"column":2},"end":{"line":28,"column":3}},"9":{"start":{"line":27,"column":4},"end":{"line":27,"column":20}},"10":{"start":{"line":29,"column":2},"end":{"line":29,"column":18}},"11":{"start":{"line":32,"column":0},"end":{"line":49,"column":1}},"12":{"start":{"line":33,"column":2},"end":{"line":43,"column":3}},"13":{"start":{"line":34,"column":4},"end":{"line":34,"column":47}},"14":{"start":{"line":35,"column":4},"end":{"line":42,"column":5}},"15":{"start":{"line":36,"column":6},"end":{"line":36,"column":34}},"16":{"start":{"line":37,"column":6},"end":{"line":39,"column":7}},"17":{"start":{"line":38,"column":8},"end":{"line":38,"column":130}},"18":{"start":{"line":41,"column":6},"end":{"line":41,"column":64}},"19":{"start":{"line":45,"column":2},"end":{"line":45,"column":53}},"20":{"start":{"line":46,"column":2},"end":{"line":46,"column":59}},"21":{"start":{"line":48,"column":2},"end":{"line":48,"column":26}},"22":{"start":{"line":51,"column":0},"end":{"line":68,"column":1}},"23":{"start":{"line":52,"column":2},"end":{"line":66,"column":3}},"24":{"start":{"line":53,"column":4},"end":{"line":53,"column":36}},"25":{"start":{"line":54,"column":4},"end":{"line":58,"column":5}},"26":{"start":{"line":55,"column":6},"end":{"line":55,"column":34}},"27":{"start":{"line":56,"column":6},"end":{"line":56,"column":44}},"28":{"start":{"line":57,"column":6},"end":{"line":57,"column":176}},"29":{"start":{"line":59,"column":4},"end":{"line":59,"column":41}},"30":{"start":{"line":60,"column":4},"end":{"line":65,"column":5}},"31":{"start":{"line":61,"column":6},"end":{"line":61,"column":70}},"32":{"start":{"line":62,"column":6},"end":{"line":64,"column":7}},"33":{"start":{"line":63,"column":8},"end":{"line":63,"column":21}},"34":{"start":{"line":67,"column":2},"end":{"line":67,"column":46}},"35":{"start":{"line":71,"column":0},"end":{"line":92,"column":1}},"36":{"start":{"line":72,"column":2},"end":{"line":90,"column":3}},"37":{"start":{"line":73,"column":4},"end":{"line":73,"column":36}},"38":{"start":{"line":74,"column":4},"end":{"line":74,"column":42}},"39":{"start":{"line":75,"column":4},"end":{"line":78,"column":5}},"40":{"start":{"line":76,"column":6},"end":{"line":76,"column":34}},"41":{"start":{"line":77,"column":6},"end":{"line":77,"column":176}},"42":{"start":{"line":79,"column":4},"end":{"line":89,"column":5}},"43":{"start":{"line":80,"column":6},"end":{"line":80,"column":36}},"44":{"start":{"line":81,"column":6},"end":{"line":83,"column":7}},"45":{"start":{"line":82,"column":8},"end":{"line":82,"column":17}},"46":{"start":{"line":84,"column":6},"end":{"line":84,"column":50}},"47":{"start":{"line":85,"column":6},"end":{"line":85,"column":74}},"48":{"start":{"line":86,"column":6},"end":{"line":88,"column":7}},"49":{"start":{"line":87,"column":8},"end":{"line":87,"column":21}},"50":{"start":{"line":91,"column":2},"end":{"line":91,"column":46}},"51":{"start":{"line":94,"column":0},"end":{"line":94,"column":36}}},"branchMap":{"1":{"line":20,"type":"if","locations":[{"start":{"line":20,"column":2},"end":{"line":20,"column":2}},{"start":{"line":20,"column":2},"end":{"line":20,"column":2}}]},"2":{"line":23,"type":"if","locations":[{"start":{"line":23,"column":2},"end":{"line":23,"column":2}},{"start":{"line":23,"column":2},"end":{"line":23,"column":2}}]},"3":{"line":34,"type":"binary-expr","locations":[{"start":{"line":34,"column":20},"end":{"line":34,"column":33}},{"start":{"line":34,"column":37},"end":{"line":34,"column":46}}]},"4":{"line":35,"type":"if","locations":[{"start":{"line":35,"column":4},"end":{"line":35,"column":4}},{"start":{"line":35,"column":4},"end":{"line":35,"column":4}}]},"5":{"line":37,"type":"if","locations":[{"start":{"line":37,"column":6},"end":{"line":37,"column":6}},{"start":{"line":37,"column":6},"end":{"line":37,"column":6}}]},"6":{"line":54,"type":"if","locations":[{"start":{"line":54,"column":4},"end":{"line":54,"column":4}},{"start":{"line":54,"column":4},"end":{"line":54,"column":4}}]},"7":{"line":62,"type":"if","locations":[{"start":{"line":62,"column":6},"end":{"line":62,"column":6}},{"start":{"line":62,"column":6},"end":{"line":62,"column":6}}]},"8":{"line":75,"type":"if","locations":[{"start":{"line":75,"column":4},"end":{"line":75,"column":4}},{"start":{"line":75,"column":4},"end":{"line":75,"column":4}}]},"9":{"line":81,"type":"if","locations":[{"start":{"line":81,"column":6},"end":{"line":81,"column":6}},{"start":{"line":81,"column":6},"end":{"line":81,"column":6}}]},"10":{"line":86,"type":"if","locations":[{"start":{"line":86,"column":6},"end":{"line":86,"column":6}},{"start":{"line":86,"column":6},"end":{"line":86,"column":6}}]}}}}
{"/Users/jtburnett/Sites/react-immutable-proptypes/babel.js":{"path":"/Users/jtburnett/Sites/react-immutable-proptypes/babel.js","s":{"1":1},"b":{},"f":{},"fnMap":{},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":4,"column":3}}},"branchMap":{}},"/Users/jtburnett/Sites/react-immutable-proptypes/src/ImmutablePropTypes.js":{"path":"/Users/jtburnett/Sites/react-immutable-proptypes/src/ImmutablePropTypes.js","s":{"1":1,"2":1,"3":1,"4":1,"5":18,"6":18,"7":2,"8":16,"9":0,"10":16,"11":1,"12":1,"13":38,"14":38,"15":10,"16":10,"17":4,"18":28,"19":39,"20":39,"21":39,"22":1,"23":1,"24":14,"25":14,"26":4,"27":4,"28":4,"29":10,"30":10,"31":19,"32":19,"33":2,"34":18,"35":1,"36":1,"37":14,"38":14,"39":14,"40":3,"41":3,"42":11,"43":10,"44":10,"45":1,"46":9,"47":9,"48":9,"49":3,"50":21,"51":1},"b":{"1":[2,16],"2":[0,16],"3":[38,0],"4":[10,28],"5":[4,6],"6":[4,10],"7":[2,17],"8":[3,11],"9":[1,9],"10":[3,6]},"f":{"1":18,"2":39,"3":38,"4":18,"5":14,"6":21,"7":14},"fnMap":{"1":{"name":"getPropType","line":18,"loc":{"start":{"line":18,"column":0},"end":{"line":18,"column":32}}},"2":{"name":"createChainableTypeChecker","line":32,"loc":{"start":{"line":32,"column":0},"end":{"line":32,"column":46}}},"3":{"name":"checkType","line":33,"loc":{"start":{"line":33,"column":2},"end":{"line":33,"column":75}}},"4":{"name":"createListOfTypeChecker","line":51,"loc":{"start":{"line":51,"column":0},"end":{"line":51,"column":46}}},"5":{"name":"validate","line":52,"loc":{"start":{"line":52,"column":2},"end":{"line":52,"column":62}}},"6":{"name":"createShapeTypeChecker","line":71,"loc":{"start":{"line":71,"column":0},"end":{"line":71,"column":44}}},"7":{"name":"validate","line":72,"loc":{"start":{"line":72,"column":2},"end":{"line":72,"column":62}}}},"statementMap":{"1":{"start":{"line":9,"column":0},"end":{"line":9,"column":37}},"2":{"start":{"line":11,"column":0},"end":{"line":11,"column":32}},"3":{"start":{"line":13,"column":0},"end":{"line":16,"column":2}},"4":{"start":{"line":18,"column":0},"end":{"line":30,"column":1}},"5":{"start":{"line":19,"column":2},"end":{"line":19,"column":34}},"6":{"start":{"line":20,"column":2},"end":{"line":22,"column":3}},"7":{"start":{"line":21,"column":4},"end":{"line":21,"column":19}},"8":{"start":{"line":23,"column":2},"end":{"line":28,"column":3}},"9":{"start":{"line":27,"column":4},"end":{"line":27,"column":20}},"10":{"start":{"line":29,"column":2},"end":{"line":29,"column":18}},"11":{"start":{"line":32,"column":0},"end":{"line":49,"column":1}},"12":{"start":{"line":33,"column":2},"end":{"line":43,"column":3}},"13":{"start":{"line":34,"column":4},"end":{"line":34,"column":47}},"14":{"start":{"line":35,"column":4},"end":{"line":42,"column":5}},"15":{"start":{"line":36,"column":6},"end":{"line":36,"column":34}},"16":{"start":{"line":37,"column":6},"end":{"line":39,"column":7}},"17":{"start":{"line":38,"column":8},"end":{"line":38,"column":130}},"18":{"start":{"line":41,"column":6},"end":{"line":41,"column":64}},"19":{"start":{"line":45,"column":2},"end":{"line":45,"column":53}},"20":{"start":{"line":46,"column":2},"end":{"line":46,"column":59}},"21":{"start":{"line":48,"column":2},"end":{"line":48,"column":26}},"22":{"start":{"line":51,"column":0},"end":{"line":68,"column":1}},"23":{"start":{"line":52,"column":2},"end":{"line":66,"column":3}},"24":{"start":{"line":53,"column":4},"end":{"line":53,"column":36}},"25":{"start":{"line":54,"column":4},"end":{"line":58,"column":5}},"26":{"start":{"line":55,"column":6},"end":{"line":55,"column":34}},"27":{"start":{"line":56,"column":6},"end":{"line":56,"column":44}},"28":{"start":{"line":57,"column":6},"end":{"line":57,"column":176}},"29":{"start":{"line":59,"column":4},"end":{"line":59,"column":41}},"30":{"start":{"line":60,"column":4},"end":{"line":65,"column":5}},"31":{"start":{"line":61,"column":6},"end":{"line":61,"column":70}},"32":{"start":{"line":62,"column":6},"end":{"line":64,"column":7}},"33":{"start":{"line":63,"column":8},"end":{"line":63,"column":21}},"34":{"start":{"line":67,"column":2},"end":{"line":67,"column":46}},"35":{"start":{"line":71,"column":0},"end":{"line":92,"column":1}},"36":{"start":{"line":72,"column":2},"end":{"line":90,"column":3}},"37":{"start":{"line":73,"column":4},"end":{"line":73,"column":36}},"38":{"start":{"line":74,"column":4},"end":{"line":74,"column":42}},"39":{"start":{"line":75,"column":4},"end":{"line":78,"column":5}},"40":{"start":{"line":76,"column":6},"end":{"line":76,"column":34}},"41":{"start":{"line":77,"column":6},"end":{"line":77,"column":180}},"42":{"start":{"line":79,"column":4},"end":{"line":89,"column":5}},"43":{"start":{"line":80,"column":6},"end":{"line":80,"column":36}},"44":{"start":{"line":81,"column":6},"end":{"line":83,"column":7}},"45":{"start":{"line":82,"column":8},"end":{"line":82,"column":17}},"46":{"start":{"line":84,"column":6},"end":{"line":84,"column":50}},"47":{"start":{"line":85,"column":6},"end":{"line":85,"column":74}},"48":{"start":{"line":86,"column":6},"end":{"line":88,"column":7}},"49":{"start":{"line":87,"column":8},"end":{"line":87,"column":21}},"50":{"start":{"line":91,"column":2},"end":{"line":91,"column":46}},"51":{"start":{"line":94,"column":0},"end":{"line":94,"column":36}}},"branchMap":{"1":{"line":20,"type":"if","locations":[{"start":{"line":20,"column":2},"end":{"line":20,"column":2}},{"start":{"line":20,"column":2},"end":{"line":20,"column":2}}]},"2":{"line":23,"type":"if","locations":[{"start":{"line":23,"column":2},"end":{"line":23,"column":2}},{"start":{"line":23,"column":2},"end":{"line":23,"column":2}}]},"3":{"line":34,"type":"binary-expr","locations":[{"start":{"line":34,"column":20},"end":{"line":34,"column":33}},{"start":{"line":34,"column":37},"end":{"line":34,"column":46}}]},"4":{"line":35,"type":"if","locations":[{"start":{"line":35,"column":4},"end":{"line":35,"column":4}},{"start":{"line":35,"column":4},"end":{"line":35,"column":4}}]},"5":{"line":37,"type":"if","locations":[{"start":{"line":37,"column":6},"end":{"line":37,"column":6}},{"start":{"line":37,"column":6},"end":{"line":37,"column":6}}]},"6":{"line":54,"type":"if","locations":[{"start":{"line":54,"column":4},"end":{"line":54,"column":4}},{"start":{"line":54,"column":4},"end":{"line":54,"column":4}}]},"7":{"line":62,"type":"if","locations":[{"start":{"line":62,"column":6},"end":{"line":62,"column":6}},{"start":{"line":62,"column":6},"end":{"line":62,"column":6}}]},"8":{"line":75,"type":"if","locations":[{"start":{"line":75,"column":4},"end":{"line":75,"column":4}},{"start":{"line":75,"column":4},"end":{"line":75,"column":4}}]},"9":{"line":81,"type":"if","locations":[{"start":{"line":81,"column":6},"end":{"line":81,"column":6}},{"start":{"line":81,"column":6},"end":{"line":81,"column":6}}]},"10":{"line":86,"type":"if","locations":[{"start":{"line":86,"column":6},"end":{"line":86,"column":6}},{"start":{"line":86,"column":6},"end":{"line":86,"column":6}}]}}}}

@@ -114,2 +114,6 @@ "use strict";

it("should ignore null keys", function () {
typeCheckPass(PropTypes.shape({ key: null }), Immutable.fromJS({ key: 1 }));
});
it("should warn for required valid types", function () {

@@ -139,3 +143,12 @@ typeCheckFail(PropTypes.shape({ key: React.PropTypes.number.isRequired }), Immutable.fromJS({}), "Required prop `key` was not specified in `testComponent`.");

});
it("should probably not validate a list, but does", function () {
var shape = {
0: React.PropTypes.number.isRequired,
1: React.PropTypes.string.isRequired,
2: React.PropTypes.string
};
typeCheckPass(PropTypes.shape(shape), new Immutable.List([1, "2"]));
});
});
});
{
"name": "react-immutable-proptypes",
"version": "0.1.1",
"version": "0.1.2",
"description": "PropType validators that work with Immutable.js.",

@@ -5,0 +5,0 @@ "main": "dist/ImmutablePropTypes.js",

# react-immutable-proptypes
PropType validators that work with Immutable.js.
## About
I got tired of seeing `React.PropTypes.instanceOf(Immutable.List)` or `React.PropTypes.instanceOf(Immutable.Map)` as PropTypes for components that should be specifying an Immutable.List of something or an Immutable.Map shape. A little "googling" came up with empty, unless you want to use Flow, which I do not. So, I wrote `react-immutable-proptypes`.
Usage is simple:
I got tired of seeing `React.PropTypes.instanceOf(Immutable.List)` or `React.PropTypes.instanceOf(Immutable.Map)` as PropTypes for components that should be specifying an `Immutable.List` **_of_** something or an `Immutable.Map` **shape**. A little *"googling"* came up empty, unless you want to use Flow, which I do not. So, I wrote `react-immutable-proptypes`.
Usage is simple, they are work with and like any `React.PropType.*` validator.
var ImmutablePropTypes = require('react-immutable-proptypes');

@@ -13,7 +16,7 @@ var MyReactComponent = React.createClass({

propTypes: {
myImmutableList: ImmutableTypes.listOf(
myRequiredImmutableList: ImmutableTypes.listOf(
ImmutableTypes.shape({
someNumberProp: React.PropTypes.number.isRequired
})
)
).isRequired
}

@@ -23,7 +26,34 @@ // ...

Please send a message or, better yet, create an issue/pull request if you know a better solution, find bugs, or want to add a feature.
## Installing
## Installation
Installing via [npmjs](https://www.npmjs.com/package/react-immutable-proptypes)
npm install --save react-immutable-proptypes
## API
React-Immutable-PropTypes has just two validators that cover 100% of my use cases, and probably 99% of everybody's use cases.
* `ImmutablePropTypes.listOf` is based on `React.PropTypes.array` and is specific to `Immutable.List`.
* `ImmutablePropTypes.shape` is based on `React.PropTypes.shape` and will try to work with any `Immutable.Iterable`. In practice, I would recommend limiting this to `Immutable.Map` or `Immutable.OrderedMap`. However, it is possible to abuse `shape` to validate an array via `Immutable.List`.
// ...
aList: ImmutablePropTypes.shape({
0: React.PropTypes.number.isRequired,
1: React.PropTypes.string.isRequired,
2: React.PropTypes.string
})
// ...
<SomeComponent aList={new Immutable.List([1, '2'])} />
That said, don't do this. Please, just... don't.
These two validators cover the output of `Immutable.fromJS` on standard JSON data sources.
## RFC
Please send a message or, better yet, create an issue/pull request if you know a better solution, find bugs, or want a feature. For example, should `listOf` work with `Immutable.Seq` or `Immutable.Range`. I can think of reasons it should, but it is not a use case I have at the present, so I'm less than inclined to implement it. Alternatively, we could add a validator for sequences and/or ranges.

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc