kensho-technologies / check-more-types Goto Github PK
View Code? Open in Web Editor NEWLots and lots of predicates and checks for JavaScript (Node/Browser)
License: MIT License
Lots and lots of predicates and checks for JavaScript (Node/Browser)
License: MIT License
check.zero('foo'); // false
check.not.zero(0); // false
Should check if both a and b have equal length
useful for schema checks, should be curried, for example
var foo = ...;
console.assert(check.eq(foo, 'foo'), 'invalid foo', foo);
// similar feature using ramda
var storage = ...;
var isValidStorage = R.partial(check.schema, {
type: R.eq('S3'),
accessKeyId: check.unemptyString,
secretAccessKey: check.unemptyString
});
la(isValidStorage(storage), 'invalid storage', storage);
It should be the same check.mixin(name, predicate)
or check.mixin(predicate, name)
.
Should guess which one is the number
check.length(1, ['foo']); // true
check.length(['foo'], 1); // true
npm i check-more-types
gives me 1.6.1. I create a file z.js containing
dmr@lapy:~/whale/node/web-hooks$ cat z.js
var check = require('check-more-types');
dmr@lapy:~/whale/node/web-hooks$ node z.js
/home/dmr/whale/node/web-hooks/node_modules/check-more-types/check-more-types.js:397
check.verify.fn(fn, 'expected predicate function');
^
TypeError: Cannot call method 'fn' of undefined
at Object.mixin (/home/dmr/whale/node/web-hooks/node_modules/check-more-types/check-more-types.js:397:20)
at module.exports (/home/dmr/whale/node/web-hooks/node_modules/check-more-types/check-more-types.js:537:11)
at Array.forEach (native)
at checkMoreTypes (/home/dmr/whale/node/web-hooks/node_modules/check-more-types/check-more-types.js:536:27)
at Object.<anonymous> (/home/dmr/whale/node/web-hooks/node_modules/check-more-types/check-more-types.js:543:2)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Should be same as arg === ''
with commit message wizard, etc.
Instead require check-types and return wrapped object
var check = require('check-more-types');
From shields http://img.shields.io/github/issues/kensho/check-more-types.svg
Major release to be compatible with check-types v2
check.same(array)
returns if all items in the array are the same (===) reference.
to avoid invalid dates
To detect if the passed value is a regular expression
Which should work with string.indexOf
result
var str = 'foo';
if (check.found(str.indexOf('oo'))) {
}
Add predicates into maybe
, verify
and not
objects
To skip manual release and allow anyone who pushes to github to release
Register with bower, add instructions.
https://www.codacy.com/project/18683/issues
Need to document check.raises
method
markdown parsing problem?
To avoid needing separate bind
or partial
calls (for methods that take more than 1 argument)
var isTitle = check.oneOf(['Mr', 'Dr', 'Ms', 'Mss']);
la(isTitle(foo), 'invalid title', foo);
using pkgfiles to measure
Allow passing predicates and strings into check.defend
function add(a, b) { return a+b; }
check.defend(add,
check.number, 'first argument should be a number',
check.number, 'second argument should be a number');
something like check.index([1, 2], 0)
For simpler combination of checks
check.or(check.unemptyString, check.number)(x);
// true if x is "foo" or 42
Minifying destroys function names. Need to register functions using names.
Too many things to work around when trying to load / overwrite the library
Should return true if the x is a number, string or boolean
maybe plain <number>.<number>.<number>
To test if an item is one of items in the list
var color = ...
la(check.oneOf(['red', 'blue', 'green'], color));
using pkgsize
Hi,
I'm attempting to use check-more-types within karma. I'm getting the following error:
Uncaught TypeError: Cannot read property 'fn' of undefined
at /node_modules/check-more-types/check-more-types.min.js:5
I'm a little stuck n this - any ideas?
Thanks,
Simple username/repo string validation
Probably generic to full source, automatic into minified file
To be aligned with check-types
a little different from typeof
which is safe from ReferenceError
Should check if given argument is unempty string and file / folder with this name exists
Should add it to check, check.maybe, check.not, etc
Generate API docs, add to README
and reuse
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.