Coder Social home page Coder Social logo

beeper's Introduction

beeper

Make your terminal beep

Useful as an attention grabber. For example, when an error happens.

Install

$ npm install beeper

Usage

import beeper from 'beeper';

await beeper();
// beep one time

await beeper(3);
// beep three times

await beeper('****-*-*');
// beep, beep, beep, beep, pause, beep, pause, beep

API

It will not beep if stdout is not TTY or if the user supplies the --no-beep flag.

beeper(count?)

beeper(melody?)

Returns a Promise<void> that is resolved after the melody has ended.

count

Type: number
Default: 1

How many times you want it to beep.

melody

Type: string

Construct your own melody by supplying a string of * for beep - for pause.

beeper's People

Contributors

antouank avatar bendingbender avatar geekab avatar richienb avatar sindresorhus avatar tremby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beeper's Issues

When using the glass tone (macintosh) the delays do not work correctly

The following Morse code beep using the glass tone doesn't work correctly as there is a problem if a beep tone takes longer than 500ms
beeper('----***')

It seems that the pause happens while the sample bell is playing - instead perhaps the pause should happen after the sample plays (?)

Test is broken: beep - count

This test does not check that there are 3 beeps.

The test suite passes both before my pull request #6 and after, even though it beeps twice before and three times after.

code: 'ERR_REQUIRE_ESM'

Hi, I just installed this package into my fresh nodejs app using

  • node/18.13.0
  • "esm": "^3.2.25"

Im getting the following error:

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/{my path}/api/node_modules/beeper/index.js not supported.
Instead change the require of index.js in null to a dynamic import() which is available in all CommonJS modules.

BELL doesn't work in cmd

From my experience, the BELL character doesn't really work in cmd. An alternative is to execute rundll32 user32.dll,MessageBeep to do the same thing.

Must use import to load ES Module error

I have tried to use this both with node and ts-node and always get "Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/user/code/testing-beeper/node_modules/beeper/index.js"

This is my tests file

import beeper from 'beeper';

beeper().then(
  () => { console.log('DONE'); },
  (error) => {
    console.log(error);
    process.exit(1);
  }
);

I'm probably doing something wrong, but I can not figure it out.

Clear MacOS Terminal badge

Is it possible to clear the red "1" badge on MacOS's Terminal app when my build has been successful? Often I instantly know why I made a syntax error and it would be nice to not have to actively go into the Terminal app to clear the badge when I don't have to.

Commonjs transforming issue for 'return' outside of function

I am getting following error

Error transforming /home/travis/build/GeekAb/picker.js/node_modules/beeper/index.js with 'commonjs' plugin: 'return' outside of function (9:1) in /home/travis/build/GeekAb/picker.js/node_modules/beeper/index.js
[08:58:22] 'rollup:iife' errored after 5.63 s
[08:58:22] SyntaxError: Error transforming /home/travis/build/GeekAb/picker.js/node_modules/beeper/index.js with 'commonjs' plugin: 'return' outside of function (9:1) in /home/travis/build/GeekAb/picker.js/node_modules/beeper/index.js

Using gulp-mocha I get a syntax error thrown by this module.

[16:25:30] SyntaxError: /Users/nackjicholson/repos/dynamoDb-marshaler/node_modules/gulp-mocha/node_modules/gulp-util/node_modules/beeper/index.js: 'return' outside of function (9:1)
   7 |  process.argv.indexOf('--beep=false') !== -1) {
   8 |  module.exports = function () {};
>  9 |  return;
     |  ^
  10 | }
  11 | 
  12 | function beep() {

This is running iojs v1.8.1

No callback after beeps have finished

I use beeper before I call process.exit().

Because of beeper's setTimeout()s, if I require('beeper')(5); process.exit(); I only hear one beep. This is on Windows, by the way.

If beeper checked for the last element in arguments being a function and treated that like a callback, I could do this, and hear 5 beeps:

require('beeper')(5, function() {
    process.exit();
});

Alternatively, beeper could return a promise so I could instead do:

`require('beeper')(5).then(process.exit);`

I can submit a PR if this idea is tenable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.