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

deku-prop-types

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deku-prop-types - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

36

lib/prop-types.js

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

var _arrayJoinConjunction = require('array-join-conjunction');
var _arrayJoinConjunction2 = _interopRequireDefault(_arrayJoinConjunction);
var _checkerFactory = require('checker-factory');

@@ -14,6 +18,6 @@

get any() {
return (0, _checkerFactory2.default)('any');
return (0, _checkerFactory2.default)();
},
get array() {
return (0, _checkerFactory2.default)('array', function (prop, key) {
return (0, _checkerFactory2.default)(function (prop, key) {
if (!Array.isArray(prop)) {

@@ -27,3 +31,3 @@ var actualType = typeof prop === 'undefined' ? 'undefined' : _typeof(prop);

return function (validator) {
return (0, _checkerFactory2.default)('arrayOf', function (prop, key) {
return (0, _checkerFactory2.default)(function (prop, key) {
if (!Array.isArray(prop)) {

@@ -43,10 +47,10 @@ var actualType = typeof prop === 'undefined' ? 'undefined' : _typeof(prop);

get bool() {
return (0, _checkerFactory2.default)('bool', 'boolean');
return (0, _checkerFactory2.default)('boolean');
},
get func() {
return (0, _checkerFactory2.default)('func', 'function');
return (0, _checkerFactory2.default)('function');
},
get instanceOf() {
return function (constructor) {
return (0, _checkerFactory2.default)('instanceOf', function (prop, key) {
return (0, _checkerFactory2.default)(function (prop, key) {
if (!(prop instanceof constructor)) {

@@ -62,10 +66,10 @@ /* eslint-disable prefer-reflect */

get number() {
return (0, _checkerFactory2.default)('number', 'number');
return (0, _checkerFactory2.default)('number');
},
get object() {
return (0, _checkerFactory2.default)('object', 'object');
return (0, _checkerFactory2.default)('object');
},
get objectOf() {
return function (validator) {
return (0, _checkerFactory2.default)('objectOf', function (prop, key) {
return (0, _checkerFactory2.default)(function (prop, key) {
var propKeys = Object.keys(prop);

@@ -85,3 +89,3 @@

return function (allowedValues) {
return (0, _checkerFactory2.default)('oneOf', function (prop, key) {
return (0, _checkerFactory2.default)(function (prop, key) {
var isAllowed = allowedValues.some(function (value) {

@@ -91,3 +95,7 @@ return value === prop;

if (!isAllowed) {
return new TypeError(key + ' is not one of the allowed values');
var valuesMsg = (0, _arrayJoinConjunction2.default)(allowedValues.map(function (v) {
return '`' + v + '`';
}), 'or');
var errMsg = 'Expected ' + key + ' to be ' + valuesMsg + ', but got `' + prop + '`';
return new TypeError(errMsg);
}

@@ -99,3 +107,3 @@ });

return function (allowedTypes) {
return (0, _checkerFactory2.default)('oneOfType', function (prop, key) {
return (0, _checkerFactory2.default)(function (prop, key) {
var isAllowed = !allowedTypes.every(function (type) {

@@ -112,3 +120,3 @@ return type.validate(prop) instanceof Error;

return function (propsObj) {
return (0, _checkerFactory2.default)('shape', function (prop, key) {
return (0, _checkerFactory2.default)(function (prop, key) {
var validators = Object.keys(propsObj);

@@ -127,4 +135,4 @@

get string() {
return (0, _checkerFactory2.default)('string', 'string');
return (0, _checkerFactory2.default)('string');
}
};
{
"name": "deku-prop-types",
"version": "0.3.0",
"version": "0.3.1",
"description": "Prop type validation for Deku components",

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

"dependencies": {
"checker-factory": "^1.0.0"
"array-join-conjunction": "^1.0.0",
"checker-factory": "^2.0.0"
}
}

@@ -25,3 +25,3 @@ # deku-prop-types

const Counter = ({props}) => <div>{props.count}</div>
Count.propTypes = {
Counter.propTypes = {
count: PropTypes.number.isRequired

@@ -28,0 +28,0 @@ }

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