1.3.0 • Published 4 years ago

parse-numeric-range v1.3.0

Weekly downloads
99,541
License
ISC
Repository
github
Last release
4 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-2410supabase-code-snippets@docusaurus/theme-common@documentumjs/remark-prism@cloudio/statex-live@clusterworks/cdocker@common-web/remark-prism@devcontainer/webtorrent@rowinbot/mdx-code-formatterjesielviana-gatsby-theme-docs@apollo/chakra-helpers@atomiks/mdx-pretty-code@autoanki/autoanki-plugin-content-pdf-fragment@autoanki/plugin-content-pdf-fragment@bitmachina/highlighter@bethq/design-system@codelloyd/gridsome-plugin-remark-embed@danpalmer/gatsby-remark-embed-gistwebtorrent-ritwebtorrent-rozzleunified-remark-prismjs@huijing/docusaurus-theme-kosong@huygn/react-showroom@elken/gatsby-remark-prismjs@egonr/rehype-prism-plus@freepress/markdown@fullstackio/docusaurus-theme-newline@girish_kumar/md-utils@innei/remark-shiki@loopholelabs/rehype-pretty-code@mxenabled/docusaurus-theme-common@multiplatform.one/ui@multiplatform.one/components@nickymeuleman/gatsby-theme-blog@nicolastoulemont/syntax-highlighter@nant-design/theme-default@eqty/risc-zero-verifier-react@mklabs/gatsby-theme-docs@jmoxey/rehype-pretty-code@joshuaavalon/gatsby-remark-prismjs@jonsully/gatsby-remark-prismjs@justsml/gatsby-remark-embed-gist@kentcdodds/md-temp@rcpress/markdown@rasahq/docusaurus-theme-tabula@rasahq/react-tabula@ryanflorence/md@rajincodingtest/rehype-pretty-code@patternplate/component-markdown@patternplate/components@noxify/gridsome-plugin-remark-embed@soraban/soraban-ui-legacy@shuding/rehype-pretty-code@retil/tool-vite-plugin-code-as-content@sergioramos/remark-prism@rocketseat/gatsby-theme-docsmitekosuruminerva-uimypluginlolrehype-pretty-coderehype-pretty-code-syncrehype-prism-advancedrehype-prism-with-pluginsrehype-prism-enhancedrehype-prism-plusremark-sugar-highremark-github-pluginrehype-highlight-code-linesrehype-custom-coderehype-gistremark-code-blockremark-highlightspresentifyremark-prismremark-prism-no-escapereact-showroomsheetfiggridsome-plugin-remark-prismjs-allhakan-doc-themelaurosilvacom-prismmdx-prismmdx-prism-2mdx-loader@wolfv/rehype-pretty-code@vendohq/design-system@unisite/gatsby-remark-prismjs@swimscribe/design-system@swimlane/docspa-remark-preset@toastdotdev/mdx@thewebforge/astro-code-blocks@vocs/rehype-pretty-code@virtualcollector/design-system
1.3.0

4 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.0.2

11 years ago

0.0.1

11 years ago