dowa means どわーw (冷笑)
冷笑を検知しますw
- Node.js >= 14 (ESM/CJS 両対応)
- ブラウザ(バンドラー経由での利用)
npm install dowa// ESM
import { contains, findAll, findMatches } from 'dowa';
// CJS
const { contains, findAll, findMatches } = require('dowa');
contains('うおw'); // => true
// relaxed モード(検知範囲を拡大)
contains('どわー', { relaxed: true });
findAll('←うおw、爆笑'); // => ['うおw', '爆笑']
// どのパターンにマッチしたかの詳細がほしい場合
findMatches('うおw、爆笑爆笑');
// => [
// { text: 'うおw', index: 0, patternId: 'stem-uo', strict: true },
// { text: '爆笑爆笑', index: 4, patternId: 'repeat-bakushou', strict: true },
// ]Important
v2 で relaxed は第2引数の boolean からオプションオブジェクトに変わりました。
findAll(text, true) → findAll(text, { relaxed: true })
findAll(text: string, options?: DowaOptions): string[] | null— マッチした冷笑の配列を返すw(見つからなければnull)contains(text: string, options?: DowaOptions): boolean— 冷笑が含まれるかを真偽値で返すwfindMatches(text: string, options?: DowaOptions): DowaMatch[] | null— どのパターンにマッチしたかの詳細(位置・パターンid・strict/relaxed)付きで返すw(見つからなければnull)。パターンごとに個別検索するため、複数パターンの一致範囲が重なる場合はfindAllの重複排除された結果とは一致しないことがあるDowaOptionsrelaxed?: boolean(デフォルト:false) —trueで検知範囲を拡大する
DowaMatchtext: string— マッチした文字列index: number— マッチ開始位置patternId: string— マッチしたパターンのid(src/lib/patterns.ts 参照)strict: boolean— そのパターンがstrictかどうか
patterns: PatternDefinition[]— 検知に使われている全パターンの定義(id/strict/source/samples)。パターンを紹介・デバッグしたい場合に
貢献方法については CONTRIBUTING.md を確認してください
Twitter (新X) で冷笑ツイートを検知するChrome/Firefox拡張機能を公開中です。
https://github.com/otnc/dowa-twitter-checker
otoneko. https://github.com/otnc