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-snippetsjesielviana-gatsby-theme-docsgridsome-plugin-remark-prismjs-allhakan-doc-themelaurosilvacom-prismmdx-prismmdx-prism-2mdx-loader@wolfv/rehype-pretty-code@vendohq/design-system@unisite/gatsby-remark-prismjs@toastdotdev/mdx@thewebforge/astro-code-blocks@vocs/rehype-pretty-code@virtualcollector/design-system@vxrn/mdx@zapier-labs/design-system@zeushq/design-system@teleport-js/teleport@egonr/rehype-prism-pluswebtorrent-ritwebtorrent-rozzleunified-remark-prismjs@loopholelabs/rehype-pretty-code@nickymeuleman/gatsby-theme-blog@nicolastoulemont/syntax-highlightermitekosuruminerva-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-showroomsheetfig@nomana-it/liberty-core@noxify/gridsome-plugin-remark-embed@patternplate/component-markdown@patternplate/components@huijing/docusaurus-theme-kosong@huygn/react-showroom@girish_kumar/md-utils@elken/gatsby-remark-prismjs@eqty/risc-zero-verifier-react@innei/remark-shiki@freepress/markdown@fullstackio/docusaurus-theme-newlinegatsby-remark-prismjsgatsby-remark-prismjs-spectregatsby-remark-visualdocsgatsby-remark-prettypapergatsby-flavored-prismjsgatsby-remark-embed-figmagatsby-remark-embed-gistgatsby-remark-embed-gist-slimgatsby-remark-embed-markdowngatsby-remark-embed-runkitgatsby-remark-embed-snippetgatsby-remark-embed-snippet-customgbunnygatsby-rehype-embed-gistgatsby-rehype-prismjsgatsby-theme-puristgatsby-theme-tfsgatsby-theme-try-ghostgatsby-plugin-bluewingsgatsby-remark-highlights@stefanprobst/rehype-shiki@stefanprobst/remark-shiki@strawberry-graphql/styleguide@supabase/code-snippets@swimlane/docspa-remark-preset@swimscribe/design-system@tamagui/code-to-html@tamagui/mdx-2dsbiserv@bitmachina/highlighter@bethq/design-system@ryanflorence/md
1.3.0

4 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.0.2

11 years ago

0.0.1

11 years ago