4chan-boards 中文文档教程
4chan-boards
获取板的名称和类型,给出其短名称(例如 /b/
)。
2.0.0 BREAKING CHANGES
枚举类型现在是 Symbol
,因此依赖虚假评估将不再有效:
const boards = require('4chan-boards')
if (boards.getType('b')) {
console.log('This will not print!')
}
相反,使用提供的枚举类型:
if (boards.getType('b') !== boards.INVALID) {
console.log('This message prints! Yay!')
}
Installation
yarn add 4chan-boards
# OR
npm install --save 4chan-boards
Usage
const boards = require('4chan-boards')
console.log(boards.getName('wsg')) // Worksafe GIF
console.log(boards.getType('b') === boards.NSFW) // true
API
Methods
获取关于板的信息(即名称或类型)。
- boards.getName(board)
- boards.getType(board)
Objects
将简称映射到全名的对象。 boards.all
包含所有板的映射,boards.sfw
仅包含 SFW 板的映射,等等。
- boards.all
- boards.admin
- boards.nsfw
- boards.sfw
Enumerated types
boards.getType(board)
将返回一个枚举类型,它已被实现为一个Symbol
- boards.ADMIN
- boards.NSFW
- boards.SFW
- boards.INVALID
4chan-boards
Get a board's name and type given its short name (eg. /b/
).
2.0.0 BREAKING CHANGES
Enumerated types are now Symbol
s, so relying on falsy evaluation will no longer work:
const boards = require('4chan-boards')
if (boards.getType('b')) {
console.log('This will not print!')
}
Instead, use the provided enumerated types:
if (boards.getType('b') !== boards.INVALID) {
console.log('This message prints! Yay!')
}
Installation
yarn add 4chan-boards
# OR
npm install --save 4chan-boards
Usage
const boards = require('4chan-boards')
console.log(boards.getName('wsg')) // Worksafe GIF
console.log(boards.getType('b') === boards.NSFW) // true
API
Methods
Get information (ie name or type) about a board.
- boards.getName(board)
- boards.getType(board)
Objects
Objects mapping short names to full names. boards.all
contains the mapping for all the boards, boards.sfw
contains mapping for only the SFW boards, etc.
- boards.all
- boards.admin
- boards.nsfw
- boards.sfw
Enumerated types
boards.getType(board)
will return an enumerated type, which has been implemented as a Symbol
- boards.ADMIN
- boards.NSFW
- boards.SFW
- boards.INVALID