You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
681 B
32 lines
681 B
const child_process = require('child_process'); |
|
|
|
const rendererd = child_process.fork(__dirname + '/rendererd', [syzoj.config.redis]); |
|
|
|
const resolver = {}; |
|
let currentId = 0; |
|
|
|
rendererd.on('message', msg => { |
|
resolver[msg.id](msg.result); |
|
delete resolver[msg.id]; |
|
}); |
|
|
|
exports.markdown = (markdownCode, callback) => { |
|
resolver[++currentId] = callback; |
|
rendererd.send({ |
|
id: currentId, |
|
type: 'markdown', |
|
source: markdownCode |
|
}); |
|
} |
|
|
|
exports.highlight = (code, lang, callback) => { |
|
resolver[++currentId] = callback; |
|
rendererd.send({ |
|
id: currentId, |
|
type: 'highlight', |
|
source: { |
|
code, |
|
lang |
|
} |
|
}); |
|
}
|
|
|