plug-message-split
Splitting and word wrap utilities for plug.dj chat messages.
Last updated 8 days ago by goto-bus-stop .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install plug-message-split 
SYNC missed versions from official npm registry.

plug-message-split

Reliable message splitting for plug.dj chat messages.

Why?

plug.dj's chat server truncates chat messages at 250 bytes (not characters). It also first html-escapes some characters before truncating. This leads to funny bugs when using certain characters:

screenshot

This library splits or truncates messages taking all known plug.dj oddities into account.

Installation

npm install --save plug-message-split

API

var msg = require('plug-message-split')
msg.split(string)
msg.splitRaw(string)
msg.truncate(string)
msg.escape(string)
msg.unescape(string)

split(string): Array<string>

Split a message for plug.dj on full words only.

splitRaw(string): Array<string>

Split a message on full characters. This might break words in two, but unicode characters will be kept intact.

truncate(string): string

Truncate a message to only full characters. Any content beyond the 250 bytes limit is discarded. It might break words, but not characters.

escape(string): string

HTML-escape a string like plug.dj escapes chat messages.

unescape(string): string

Reverse plug.dj's chat message escaping. Useful for normalizing incoming chat messages.

License

MIT

Current Tags

  • 2.0.0                                ...           latest (8 days ago)

5 Versions

  • 2.0.0                                ...           8 days ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Downloads
Today 0
This Week 1
This Month 17
Last Day 0
Last Week 15
Last Month 3
Dependencies (0)
None
Dev Dependencies (2)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |