Git Product home page Git Product logo

check's People

Contributors

parzhitsky avatar

Watchers

 avatar

check's Issues

"NAND" logic gates

check.nand(false, false);	// true
check.nand(false, true);	// true
check.nand(true,  false);	// true
check.nand(true,  true);	// false

Add method `.isFunction()` (and opposite)

function func() { /* ... */ }

check.isFunction(func); // true
check.isFunction(() => {}); // true
check.isFunction({}); // false

check.isNotFunction(func); // false
check.isNotFunction(() => {}); // false
check.isNotFunction({}); // true

"AND" logic gates

check.and(false, false);	// false
check.and(false, true);		// false
check.and(true,  false);	// false
check.and(true,  true);		// true

Add method `check.isGenerator()` (and opposite)

check.isGenerator(function*(){}); // true
check.isGenerator(function(){}); // false
check.isGenerator(42); // false

check.isNotGenerator(function*(){}); // false
check.isNotGenerator(function(){}); // true
check.isNotGenerator(42); // true

Allow to install `check` via `<script>` tag

Alongside with using check as a node module…

npm install checkjs --save

… allow installation of it though the <script> tag in the <html> page

<script src="./lib/check.js"></script>

Help with translation

English is not my native language (and obviously will never be). So feel free to spot here in the comments any mistake that you can see in readme docs or commit names or issues etc.

Not clear environment expectations

Some parts of the code use silly protections that can be useful only in old-standard environments:

if (typeof Symbol !=== "undefined") && input[Symbol.iterator]

while others may cause fatal SyntaxError in these environments:

(...args) => check[methodName](...args)

So, should the check be based on old or new standards?

"OR" logic gates

check.or(false, false);		// false
check.or(false, true);		// true
check.or(true,  false);		// true
check.or(true,  true);		// true

Add method `.hasProperty` (and the opposite one)

let object = {
    prop1: { foo: { bar: 5 } },
    prop2: { foo: { bar: undefined } },
    prop3: 42
};

// alias: check.prop()
check.hasProperty(object, "prop1"); // true
check.hasProperty(object, "prop5"); // false
check.hasProperty(object, "bar"); // false

check.hasProperty(object, ["prop1", "bar"]); // false
check.hasProperty(object, ["prop1", "foo", "bar"]); // true
check.hasProperty(object, ["prop2", "foo", "bar"]); // true (!)
check.hasProperty(object, ["prop3", "foo", "bar"]); // false

// alias: check.noprop()
check.hasNoProperty(object, "prop1"); // false
check.hasNoProperty(object, "prop5"); // true
check.hasNoProperty(object, "bar"); // true

check.hasNoProperty(object, ["prop1", "bar"]); // true
check.hasNoProperty(object, ["prop1", "foo", "bar"]); // false
check.hasNoProperty(object, ["prop2", "foo", "bar"]); // false (!)
check.hasNoProperty(object, ["prop3", "foo", "bar"]); // true

Add new method `.isCallable()` (and the opposite)

check.isCallable(function() {}); // true
check.isCallable(() => {}); // true
check.isCallable({}); // false

check.isNotCallable(function() {}); // false
check.isNotCallable(() => {}); // false
check.isNotCallable({}); // true

Add various methods

to the chapter Types:

  • cheek.isArraylike(input)

to the chapter Array:

  • cheek.arrayContains(array: any[], element: any)
  • cheek.hasFirst(array: any[], element: any)
  • cheek.hasLast(array: any[], element: any)

to the chapter String:

  • cheek.isEmptyString(input: string)
  • cheek.stringContains(source: string, substr: string)
  • cheek.startsWith(source: string, substr: string)
  • cheek.endsWith(source: string, substr: string)

to the chapter Number:

  • cheek.isZero(input: number)

to the chapter Other:

  • cheek.inputs(inputs: any[]) (analogue of cheek.bundle())
  • cheek.every(inputs: any[]) (analogue of cheek.everyInput())
  • cheek.some(inputs: any[]) (analogue of cheek.someInput())

How to set up the chain at the first place?

At least two options are possible:

  • Verbose:
    check.input(42).chain(logic);
  • Compact:
    check.input(42)[logic]();

where logic may take one of the following string-values:

  • "and" - conjuction;
  • "or" - disjunction;
  • "nor" - negated disjunction;
  • "xor" - exclusive disjunction;

Both options may be used along one with another as alias to each other.

How to get final result of the chain?

The final result of the chain should always be boolean, no matter how long the chain is. But how to retrieve the result when needed?

One option is to use function .resolve() (or some short alias like .so()) at the end of the chain. It is easy to setup but not so convenient to use. There should be a better way.

Another option is to create new class extends Boolean {} and alter it to our needs. Gotta check this out.

"XOR" logic gates

check.xor(false, false);	// false
check.xor(false, true);		// true
check.xor(true,  false);	// true
check.xor(true,  true);		// false

"NOR" logic gates

check.nor(false, false);	// true
check.nor(false, true);		// false
check.nor(true,  false);	// false
check.nor(true,  true);		// false

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.