6 process.stdout.write('\u0007');
9 function melodicalBeep(val, cb) {
10 if (val.length === 0) {
15 setTimeout(function () {
16 if (val.shift() === '*') {
20 melodicalBeep(val, cb);
24 module.exports = function (val, cb) {
25 if (!process.stdout.isTTY ||
26 process.argv.indexOf('--no-beep') !== -1 ||
27 process.argv.indexOf('--beep=false') !== -1) {
31 cb = cb || function () {};
33 if (val === parseInt(val)) {
35 throw new TypeError('Negative numbers are not accepted');
43 for (var i = 0; i < val; i++) {
44 setTimeout(function (i) {
50 }, BEEP_DELAY * i, i);
55 } else if (typeof val === 'string') {
56 melodicalBeep(val.split(''), cb);
58 throw new TypeError('Not an accepted type');