- Notifications
You must be signed in to change notification settings - Fork1
JaKXz/xor-js
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This package provides a rudimentary XOR check of a list of arguments in JS. Given any arity of arguments it will return true iff onlyone of the arguments istruthy, otherwise, it will return false.
npm install xor-js# XOR ;)yarn add xor-jsA powerful application is to combine this package withinvariant to create rules for your API.
importxorfrom'xor-js';importinvariantfrom'invariant';functionMyComponent({ primary, secondary, tertiary, ...props}){invariant(xor(primary,secondary,tertiary),'Only one of primary, secondary, or tertiary may be true.')return(...);}
This was adapted and inspired fromthis post on Code Review.
About
XOR for a list of JS args
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.