本文整理汇总了TypeScript中@ts-common/iterator.isArray函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isArray函数的具体用法?TypeScript isArray怎么用?TypeScript isArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isArray函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
export const visit = <T>(value: Json, visitor: Visitor<T>) =>
value === null ? visitor.asNull() :
typeof value === "boolean" ? visitor.asBoolean(value) :
typeof value === "string" ? visitor.asString(value) :
typeof value === "number" ? visitor.asNumber(value) :
_.isArray(value) ? visitor.asArray(value) :
visitor.asObject(value)
示例2: async
const main = async (dir: string) => {
try {
const list = fs.recursiveReaddir(dir)
for await (const file of list) {
const f = path.parse(file)
if (f.base === "readme.md") {
console.log(`processing ${file}`)
const content = (await fs.readFile(file)).toString()
const readMe = cm.parse(content)
const set = new Set<string>()
for (const c of cm.iterate(readMe.markDown)) {
if (
c.type === "code_block" &&
c.info !== null &&
c.info.startsWith("yaml") &&
c.literal !== null
) {
const y = (yaml.load(c.literal) as Code)["input-file"]
if (typeof y === "string") {
set.add(y)
} else if (it.isArray(y)) {
for (const i of y) {
set.add(i)
}
}
}
}
const readMeMulti = cm.createNode(
"document",
cm.createNode(
"heading",
cm.createText("Multi-API support for AutoRest v3 generators")
),
cm.createNode(
"block_quote",
cm.createNode(
"paragraph",
cm.createText("see https://aka.ms/autorest")
)
),
cm.createCodeBlock(
"yaml $(enable-multi-api)",
yaml.dump({ "input-file": it.toArray(set) }, { lineWidth: 1000 })
)
)
const x = cm.markDownExToString({ markDown: readMeMulti })
fs.writeFile(path.join(f.dir, "readme.enable-multi-api.md"), x)
}
}
} catch (e) {
console.error(e)
}
}