Git Product home page Git Product logo

elliptical-number's Introduction

elliptical-number

Build Status

Elliptical phrases for numbers (Integer, Decimal, DigitString, Ordinal)

Installation

npm install elliptical-number

Usage

/** @jsx createElement */
import { DigitString, Integer, Ordinal, Decimal } from 'elliptical-number'
import { createElement, compile } from 'elliptical'

const parse = new compile(
  <sequence>
    <Integer max={99} min={0} id='numBottles' />
    <literal text=' bottles of beer on the wall' />
  </sequence>
}

parse('73 bottles of beer on the wall')
/* [{
  words: [
    {text: '73', input: true, argument: 'number'},
    {text: ' bottles of beer on the wall', input: true}
  ],
  score: 1,
  result: {numBottles: 73}
}] */

Reference

Integer

Accepts integers specified numerically. These can be negative. Does not currently accept numbers that are spelled out, or numbers with thousands separators.

Result

Number - A numeric representation of the input number.

Props

  • argument: String - The label text for this phrase. Defaults to number.
  • max: Number - the highest acceptable integer. No limit by default.
  • min: Number - the lowest acceptable integer. No limit by default.

DigitString

Designed to accept strings that happen to contain numbers. This should be used in place of Integer for things like phone numbers, zip codes, and time markers. While these things are represented with digits, they do not technically represent numbers, and should be managed with strings.

Only accept digits. That is, all inputs will be strings that can be parsed as positive integers.

Result

String - the string the user entered.

Props

  • argument: String - The label text for this phrase. Defaults to number.
  • max: Number - the highest acceptable integer. No limit by default.
  • min: Number - the lowest acceptable integer. Defaults to 0.
  • maxLength: Number - the highest acceptable string length. No limit by default.
  • minLength: Number - the lowest acceptable string length. Defaults to 1.

Ordinal

Accepts numbers specified in ordinal form. That is, numbers like 1st, 3rd, 12th, 202nd, etc.

Result

Number - A numeric representation of the input number.

Props

  • argument: String - The label text for this phrase. Defaults to number.
  • max: Number - the highest acceptable integer. No limit by default.
  • min: Number - the lowest acceptable integer. No limit by default.

Decimal

Accepts a fixed-point decimal specified numerically. These can be negative. Leading zero is optional.

Result

Number - A numeric representation of the input number.

Props

  • argument: String - The label text for this phrase. Defaults to number.
  • max: Number - the highest acceptable decimal. No limit by default.
  • min: Number - the lowest acceptable decimal. No limit by default.

elliptical-number's People

Contributors

brandonhorst avatar jmalins avatar

Watchers

 avatar  avatar

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.