New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bluesocks

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bluesocks

Bluesocks is a lightweight lexer for Javascript

  • 0.7.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

bluesocks

Bluesocks is a lightweight lexer in Javascript

let { lexer, rule } = require('bluesocks');

let rules = {
	default: [
		rule("PERIOD1", /\./, "othercontext"), //push othercontext
		rule("NOTPERIOD1", /[^\.]+/)
	],
	othercontext: [
		rule("PERIOD2", /\./, "<"), //pop othercontext
		rule("NOTPERIOD2", /[^\.]+/)
	]
}


lex = lexer("This is a test. This is a test. This is a test.", "test", rules);

let token = lex.next();
while(!token.done) {
	switch (token.value.type) {
		case "PERIOD1":
			console.log("We switched to default context");
			break;
		case "NOTPERIOD1":
			console.log(`We found a non-period token: "${token.value.data}"`);
			break;
		case "PERIOD2":
			console.log("We switched to othercontext");
			break;
		case "NOTPERIOD2":
			console.log(`We found a non-period token: "${token.value.data}"`);
			break;
		}
	token = lex.next();
}

Keywords

FAQs

Package last updated on 18 Sep 2017

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