npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

alexa-speech-utils

v0.2.0

Published

Helper functions for building speech responses

Downloads

5

Readme

alexa-speech-utils

Nodejs module that provides helper functions for generating text or SSML responses in the English language Designed for use with Alexa or other speech output devices. Contributions are welcome - if you don't find a utility function that you want - add it!

Loading module

When loading the module, you can pass in an options structure (optional) that specifies how the module should run. Currently the only supported parameter is "speakTag" which will include SSML tags around the response.

const alexautils = require('alexa-speech-utils');
const utils = alexautils({speakTag: true});

This will cause output to be returned wrapped with tags

Available functions

and

or

and takes a list of items and combines them with "and" or takes a list of items and combines them with "or"

and(items, options)
or(items, options)

The arguments to and or or are:

  • items - an array of items to combine together into a string
  • options - an optional object providing additional details to and

The options structure is composed of the following fields:

{
  pause - Amount of time to pause between each item - if specified, the returned string will be in SSML format
  preseparator - A separator which will be used between items - this separator will come before the 'and' or 'or'
  postseparator - A separator which will be used between items - this separator will come after the 'and' or 'or'
  locale - locale to use - supports en-US, en-GB, and de-DE
}

Example:

and(['milk', 'cream', 'honey'], {pause:'1s'});

will return the string

milk <break time='1s'/> cream <break time='1s'/> and honey
or(['milk', 'cream', 'honey']);

will return the string

milk, cream, or honey

numberOfItems

numberOfItems takes a list of number along with singular and plural nouns to return a string

numberOfItems(number, singular, plural)

Example:

numberOfItems(0, 'dog', 'dogs');

will return the string

no dogs

relativeDate

relativeDate takes a date and formats it relative to the current date, using today, yesterday, tomorrow, and only mentioning the year if it differs from the current year. You can optionally include the time as well.

relativeDate(date, options)

The options structure is composed of the following fields:

{
  includeTime - If set, hours and minutes will be included in the response
}

Example:

const now = Date.now();
const date = new Date(now);
date.setDate(date.getDate() - 1);

relativeDate(date);

will return the string

yesterday

formatCurrency

amount numerical amount to turn into a currency locale locale to determine the appropriate currency symbol - currently supports en-US, en-GB, and de-DE. Default is en-US

formatCurrency(amount, locale)

Example:

formatCurrency(100, 'en-GB');

will return the string

£100

Contributing - bug fixes and new functionality

Contributions are welcome! Please feel free to fork this code and submit pull requests, for bug fixes or feature enhancements.

  1. Fork it!
  2. Create your featured branch: git checkout -b my-feature
  3. Commit your changes: git commit -m 'add some feature'
  4. Push to the branch: git push origin my-feature
  5. Submit a pull request

Many Thanks!