Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

XOR for a list of JS args

License

NotificationsYou must be signed in to change notification settings

JaKXz/xor-js

Repository files navigation

Node.js CInpm Versionnpm Downloads Monthly

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.

Example Usage

npm install xor-js# XOR ;)yarn add xor-js

A 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(...);}

Credits

This was adapted and inspired fromthis post on Code Review.

About

XOR for a list of JS args

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp