Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
A JavaScript library for comfortable 2ch watching.
Install the module with: npm install 2ch --save
var watcher = new require('2ch').ThreadWatcher('iPhone', /パズル&ドラゴンズ/);
watcher.on('update', function(messages) {
// do something.
});
watcher.start();
new ThreadWatcher(bbsName, query, interval [, bbsMenu ])
A string which is a valid board name in 2ch.
A string or RegExp which is used to find the watched thread.
A number determining the update interval. It is at least 5000.
A BbsMenu instance object. In most cases, there is no need to specify.
The ThreadWatcher class inherited from EventEmitter2. So you can use EventEmitter2 methods basically.
Start watching 2ch.
Stop watching 2ch.
Return true
, when waching is started. Return false
, otherwise.
The update
event is emitted, when the watched thread has new messages.
The callback take the messages
argument.
watcher.on('update', function(messages) {
messages.forEach(function(message) {
console.log(
message.number,
message.postedAt.format('YYYY/MM/DD HH:mm:ss'), // moment object.
message.name,
message.mail,
message.tripId,
message.body
);
});
});
The error
event is emitted, when a error occured in the library.
The callback take the error
argument.
If there is no listener for it, then the default action is to print a stack trace and exit the program.
The reload
event is emitted, when the watched thread is reloaded for deleting a message.
The callback take the title
argument.
The begin
event is emitted, when the watched thread is found.
The callback take the title
argument.
The end
event is emitted, when the watched thread is ended.
The callback take the title
argument.
The notfound
event is emitted, when the watched thread is not found by specified query.
var ThreadWatcher = require('2ch').ThreadWatcher,
watcher = new ThreadWatcher('番組ch(NHK)', /NHK総合を常に実況し続けるスレ/, 5000),
loaded = false;
watcher.on('update', function(messages) {
if (!loaded) {
loaded = true;
return;
}
messages.forEach(function(message) {
console.log(
message.number,
message.name.replace(/<[^<>]+>/g, ''),
message.postedAt.format('YYYY/MM/DD HH:mm:ss'), // moment object.
message.tripId,
message.body.replace(/<[^<>]+>/g, '')
);
});
});
watcher.on('error', function(error) {
console.log(error);
watcher.stop();
});
watcher.on('reload', function(title) {
console.log(title, 'のスレッドが再読込されました');
loaded = false;
});
watcher.on('begin', function(title) {
console.log(title, 'のスレッドが開始しました');
});
watcher.on('end', function(title) {
console.log(title, 'のスレッドが終了しました');
});
watcher.start();
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Copyright (c) 2013 Shogo Iwano Licensed under the MIT license.
FAQs
A JavaScript library for comfortable 2ch watching.
The npm package 2ch receives a total of 19 weekly downloads. As such, 2ch popularity was classified as not popular.
We found that 2ch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.