Skip to content

Repository files navigation

dowa

npm version CI License: MIT Node code style: prettier 技術者倫理|遵守済み

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 })

API

  • findAll(text: string, options?: DowaOptions): string[] | null — マッチした冷笑の配列を返すw(見つからなければ null
  • contains(text: string, options?: DowaOptions): boolean — 冷笑が含まれるかを真偽値で返すw
  • findMatches(text: string, options?: DowaOptions): DowaMatch[] | null — どのパターンにマッチしたかの詳細(位置・パターンid・strict/relaxed)付きで返すw(見つからなければ null)。パターンごとに個別検索するため、複数パターンの一致範囲が重なる場合は findAll の重複排除された結果とは一致しないことがある
  • DowaOptions
    • relaxed?: boolean (デフォルト: false) — true で検知範囲を拡大する
  • DowaMatch
    • text: 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

Chrome拡張機能 / Firefox拡張機能

著者

otoneko. https://github.com/otnc

ライセンス

MIT License

About

dowa means どわーw (冷笑) / 冷笑を検知しますw

Resources

Contributing

Stars

16 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages

Generated from oto-lab/npm-package.ts