本文整理匯總了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)
}
}