Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

consumed

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

consumed

Easy string consumption

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by600%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status downloads npm Code Climate Test Coverage dependencies

consumed

Easy string consumption for parsing and lexing.

Installation

npm install --save consumed

Summary

Create a new instance of the Consumed object and pass in a string. Then you can use a single letter or a regex pattern to grab part of the string and remove it from the original.

Usage

var Consumed = require('consumed');
var consumer = new Consumed('foo bar baz');

// Get up to the first instance of a letter
var match = consumer.consumeTill('b');
console.log(match); // 'foo '
console.log(consumer.str); // 'bar baz'

// Get up to the first instance of a letter, but include that letter
match = consumer.consumeTill('b', /*inclusive=*/true);
console.log(match); // 'bar b'
console.log(consumer.str); // 'az'

// Or match a pattern
consumer = new Consumed('foo bar baz');
match = consumer.consume(/.*(.)\1/);
console.log(match); // 'foo'
console.log(consumer.str); // ' bar baz'

Contributing

I'll be happy to merge any pull request that adds value and has passing tests. Be sure to add a test both for node and for the browser. Tests are run with grunt.

Keywords

FAQs

Package last updated on 03 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc