New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ck-if

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

ck-if

elegantly solve ifelse nesting

unpublished
latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

优雅的解决 if-else 嵌套循环

const ifElse = require('ckif').ifelse//引入并创建

function say(res) {
  console.log(res)
  return res
}
// 且方法示例
function and(a, b, c, d) {
  console.log(`且方法示例`);
  ifElse.new(a == "橘色").run(say, "这是橘色")
  .next(b == "狗").run(say, "这是狗") //支持函数
  .next(c == 13).run(say, "他会叫") //这里条件不等,所以不会执行,后面的也不会
  .next(d == "15cm").run(say, "它高 15 厘米")

  .new(a == "橘色").run(say, "这是橘色")
  .next(b == "狗").run(say, "这是狗") //支持函数
  .next(c == 13).run(say, "他会叫") //这里条件成立,所以会执行
  .next(d == "15cm").run(say, "它高15厘米")

// 或方法示例

  .new(a == "橘色").run(say, "或方法,这是白色")
  .next(b == "狗").run(say, "它会卖萌")
  .next(c == 3 || c == 5 && d == "15cm")
  .run(say, "我记得它可能3岁或5岁").run(say, "但它的身高一定是15cm")

}

and("橘色", "狗", "3", "15cm")

Keywords

if

FAQs

Package last updated on 05 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts