1.3.0 • Published 3 years ago

parse-numeric-range v1.3.0

Weekly downloads
99,541
License
ISC
Repository
github
Last release
3 years ago

node-parse-numeric-range

Parses expressions like 1-10,20-30. Returns an energetic (as opposed to lazy) array.

Supported Expressions

Comprehensive supported expression examples:

Expressionresult
[]
11
1,21,2
-10-10
-3,-3-3, -3
-1-2,-2-1,0,1,2,-2
-1--2-1,-2
-1..2,-2-1,0,1,2,-2
-1...3,-2-1,0,1,2,-2
1⋯31,2
1…31,2
1‥31,2,3

What's this useful for? Well, letting users input these sorts of things and then making them programmatically useful.

Usage

First, npm install parse-numeric-range.

const rangeParser = require("parse-numeric-range");

const numbers = rangeParser("4,6,8-10,12,14..16,18,20...23");

console.log(
  `The first ${numbers.length} composite numbers are: ${numbers.join(", ")}`,
);

ES6

import rangeParser from "parse-numeric-range";

const numbers = rangeParser("4,6,8-10,12,14..16,18,20...23");

console.log(
  `The first ${numbers.length} composite numbers are: ${numbers.join(", ")}`,
);
@docusaurus-azuread/theme-classicgatsby-theme-ghost-reloadedwebtorrent-jaligit-bunnywebtorrent-fork@yiqilaitech/gatsby-theme-docs@jakedeichert/create-app@infinitebrahmanuniverse/nolb-parse-@everything-registry/sub-chunk-2410@innei/remark-shiki@loopholelabs/rehype-pretty-code@jmoxey/rehype-pretty-code@mklabs/gatsby-theme-docs@nant-design/theme-default@multiplatform.one/components@multiplatform.one/ui@nickymeuleman/gatsby-theme-blog@nicolastoulemont/syntax-highlighter@joshuaavalon/gatsby-remark-prismjs@jonsully/gatsby-remark-prismjs@justsml/gatsby-remark-embed-gist@fullstackio/docusaurus-theme-newline@girish_kumar/md-utils@freepress/markdown@huijing/docusaurus-theme-kosong@huygn/react-showroom@mxenabled/docusaurus-theme-commonunified-remark-prismjswebtorrent-ritwebtorrent-rozzle@shuding/rehype-pretty-code@stefanprobst/rehype-shiki@stefanprobst/remark-shiki@strawberry-graphql/styleguidemitekosuru@patternplate/component-markdown@patternplate/components@swimlane/docspa-remark-preset@swimscribe/design-system@teleport-js/teleport@sergioramos/remark-prismlaurosilvacom-prism@retil/tool-vite-plugin-code-as-content@rocketseat/gatsby-theme-docs@rowinbot/mdx-code-formatter@noxify/gridsome-plugin-remark-embed@rcpress/markdown@kentcdodds/md-temp@rajincodingtest/rehype-pretty-code@rasahq/react-tabula@rasahq/docusaurus-theme-tabula@ryanflorence/md@zapier-labs/design-system@egonr/rehype-prism-plus@elken/gatsby-remark-prismjs@zeushq/design-system@eqty/risc-zero-verifier-react@unisite/gatsby-remark-prismjs@virtualcollector/design-system@supabase/code-snippets@vocs/rehype-pretty-codeminerva-ui@vendohq/design-system@tamagui/code-to-html@toastdotdev/mdxmdx-prismmdx-prism-2mdx-loader@thewebforge/astro-code-blocksdsbiserv@autoanki/autoanki-plugin-content-pdf-fragment@autoanki/plugin-content-pdf-fragmentpresentifygridsome-plugin-remark-prismjs-all@bethq/design-systemgatsby-remark-visualdocsgatsby-flavored-prismjsgatsby-theme-puristgatsby-theme-tfsgatsby-theme-try-ghostgbunnygatsby-rehype-embed-gistgatsby-rehype-prismjsgatsby-remark-embed-figmagatsby-remark-embed-gistgatsby-remark-embed-gist-slimgatsby-remark-embed-markdowngatsby-remark-embed-runkitgatsby-remark-highlightsgatsby-remark-embed-snippetgatsby-remark-embed-snippet-customgatsby-remark-prettypapergatsby-remark-prismjsgatsby-remark-prismjs-spectre@apollo/chakra-helpersgatsby-plugin-bluewings@common-web/remark-prism@clusterworks/cdocker@cloudio/statex-live@codelloyd/gridsome-plugin-remark-embed
1.3.0

3 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.0.2

9 years ago

0.0.1

10 years ago