dowa
v2.0.2
Published
冷笑を検知しますw
Readme
dowa
dowa means どわーw (冷笑)
冷笑を検知しますw
動作環境
- Node.js >= 14 (ESM/CJS 両対応)
- ブラウザ(バンドラー経由での利用)
インストール
npm install dowa使い方
// ESM
import { findAll, contains } from 'dowa';
// CJS
const { findAll, contains } = require('dowa');
findAll('←うおw、爆笑'); // => ['うおw', '爆笑']
contains('うおw'); // => true
// relaxed モード(検知範囲を拡大)
contains('どわー', { relaxed: true });
// どのパターンにマッチしたかの詳細がほしい場合
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 })
API
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)。パターンを紹介・デバッグしたい場合に
著者
otoneko. https://github.com/otnc
貢献について
貢献方法については ./CONTRIBUTING.md を確認してください
その他
Twitter (新X) で冷笑ツイートを検知するChrome/Firefox拡張機能を公開中です。
https://github.com/otnc/dowa-twitter-checker
Chrome拡張機能: https://chromewebstore.google.com/detail/kkojaplhlbbildhofdophfadmbdholdn
Firefox拡張機能: https://addons.mozilla.org/firefox/addon/%E5%86%B7%E7%AC%91%E3%83%81%E3%82%A7%E3%83%83%E3%82%AB%E3%83%BC-for-twitter/
