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

deku-prop-types-immutable

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deku-prop-types-immutable - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

77

lib/index.js

@@ -33,40 +33,93 @@ 'use strict';

var immutableCheckerFactory = function immutableCheckerFactory(name) {
var instanceCheck = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
var immutableCheckerFactory = function immutableCheckerFactory(name, validator) {
var instanceCheck = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
return (0, _checkerFactory2.default)(name, function (prop, key) {
var typeError = instanceCheck ? immutableInstanceCheck(name, prop, key) : immutableTypeCheck(name, prop, key);
if (typeError) {
return typeError;
}
return validator(prop, key);
});
};
var listConsistsOf = function listConsistsOf(immutableType) {
return function (validator) {
return immutableCheckerFactory(immutableType, function (prop, key) {
var anyErrors = prop.some(function (p) {
return validator.validate(p) instanceof Error;
});
if (anyErrors) {
return new TypeError(key + ' does not consist of the correct type');
}
});
};
};
var mapConsistsOf = function mapConsistsOf(immutableType, instanceCheck) {
return function (validator) {
return immutableCheckerFactory(immutableType, function (prop, key) {
var anyErrors = prop.some(function (k, v) {
return validator.validate(v) instanceof Error;
});
if (anyErrors) {
return new TypeError(key + ' does not consist of the correct type');
}
}, instanceCheck);
};
};
module.exports = {
get Iterable() {
get iterable() {
return immutableCheckerFactory('Iterable');
},
get List() {
get iterableOf() {
return mapConsistsOf('Iterable');
},
get list() {
return immutableCheckerFactory('List');
},
get Map() {
get listOf() {
return listConsistsOf('List');
},
get map() {
return immutableCheckerFactory('Map');
},
get OrderedMap() {
get mapOf() {
return mapConsistsOf('Map');
},
get orderedMap() {
return immutableCheckerFactory('OrderedMap');
},
get OrderedSet() {
get orderedMapOf() {
return mapConsistsOf('OrderedMap');
},
get orderedSet() {
return immutableCheckerFactory('OrderedSet');
},
get Record() {
return immutableCheckerFactory('Record', true);
get orderedSetOf() {
return listConsistsOf('OrderedSet');
},
get Set() {
get record() {
return immutableCheckerFactory('Record', undefined, true);
},
get set() {
return immutableCheckerFactory('Set');
},
get Seq() {
get setOf() {
return listConsistsOf('Set');
},
get seq() {
return immutableCheckerFactory('Seq');
},
get Stack() {
get seqOf() {
return listConsistsOf('Seq');
},
get stack() {
return immutableCheckerFactory('Stack');
},
get stackOf() {
return listConsistsOf('Stack');
}
};

2

package.json
{
"name": "deku-prop-types-immutable",
"version": "0.1.0",
"version": "0.2.0",
"description": "Immutable prop type validation for Deku components",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -28,3 +28,3 @@ # deku-prop-types-immutable

count: PropTypes.number.isRequired,
config: ImmutablePropTypes.Map
config: ImmutablePropTypes.map
}

@@ -44,3 +44,3 @@

count: PropTypes.number.isRequired,
config: ImmutablePropTypes.Map
config: ImmutablePropTypes.map
},

@@ -56,21 +56,37 @@ render({props}) {

## Supported types
### ImmutablePropTypes.Iterable
### ImmutablePropTypes.iterable
Validate prop is an [Immutable.Iterable](https://facebook.github.io/immutable-js/docs/#/Iterable)
### ImmutablePropTypes.List
### ImmutablePropTypes.iterableOf
Validate each property's value is of a certain type
### ImmutablePropTypes.list
Validate prop is an [Immutable.List](https://facebook.github.io/immutable-js/docs/#/List)
### ImmutablePropTypes.Map
### ImmutablePropTypes.listOf
Validate each value is of a certain type
### ImmutablePropTypes.map
Validate prop is an [Immutable.Map](https://facebook.github.io/immutable-js/docs/#/Map)
### ImmutablePropTypes.OrderedMap
### ImmutablePropTypes.mapOf
Validate each property's value is of a certain type
### ImmutablePropTypes.orderedMap
Validate prop is an [Immutable.OrderedMap](https://facebook.github.io/immutable-js/docs/#/OrderedMap)
### ImmutablePropTypes.OrderedSet
### ImmutablePropTypes.orderedMapOf
Validate each property's value is of a certain type
### ImmutablePropTypes.orderedSet
Validate prop is an [Immutable.OrderedSet](https://facebook.github.io/immutable-js/docs/#/OrderedSet)
### ImmutablePropTypes.Record
### ImmutablePropTypes.orderedSetOf
Validate each value is of a certain type
### ImmutablePropTypes.record
Validate prop is an [Immutable.Record](https://facebook.github.io/immutable-js/docs/#/Record)
### ImmutablePropTypes.Set
### ImmutablePropTypes.set
Validate prop is an [Immutable.Set](https://facebook.github.io/immutable-js/docs/#/Set)
### ImmutablePropTypes.Seq
### ImmutablePropTypes.setOf
Validate each value is of a certain type
### ImmutablePropTypes.seq
Validate prop is an [Immutable.Seq](https://facebook.github.io/immutable-js/docs/#/Seq)
### ImmutablePropTypes.Stack
### ImmutablePropTypes.seqOf
Validate each value is of a certain type
### ImmutablePropTypes.stack
Validate prop is an [Immutable.Stack](https://facebook.github.io/immutable-js/docs/#/Stack)
### ImmutablePropTypes.stackOf
Validate each value is of a certain type
## License
MIT © [Dustin Specker](https://github.com/dustinspecker)
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