npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fx23

v2.1.1

Published

Text scanner for Node.js

Downloads

10

Readme

Fx23

MEAN Module Build Status npm version Node.js Version

Text scanner, available in Node.js, C# and Objective-C.

Installation:

# yarn
yarn add fx23
# npm
npm install fx23 --save

Run tests:

# yarn
yarn test
# npm
npm test

API

Fx23StringReader Class (Core Members)

Properties

  • collectLineInfo counts lineIndex and columnIndex during each read operation, default is false.
  • index the index position of current character.
  • columnIndex zero-based column number of current character at current line.
  • lineIndex zero-based line number of current character.
  • visibleIndex the index position of current character without newline characters.
  • length total length of the string.

Methods

  • hasNext returns false if no more character to read.
  • peek returns the next character without moving the internal index.
  • next returns the next character and move the internal index forward.
  • mark marks a flag at current position.
  • collect returns a sub-string from last marked position to current position.
  • nextOverride implementated by subclass.
  • peekOverride implementated by subclass.

Fx23StringReader Class (Extension Members)

These methods are built onto the core members.

Methods

  • collectWhile moves forward while condition is true, and returns the string scanned.
  • skipWhile moves forward while condition is true.
  • moveToContent moves to next non-whitespace character.
  • skipLine moves to next line.
  • collectLine moves to next line and returns current line.

Example

// ES6+
const { Fx23StringReader } = require('fx23');

// the string we need to scan
const str = '   abcdef\r\na b c\nMgen123abc';

// initialize the reader
const reader = new Fx23StringReader(str);
// counts lineIndex and columnIndex during each read operation
reader.collectLineInfo = true;

console.log('Move to content');
reader.moveToContent();
printInfo(reader);
/*
 Reader position:
 "   abcdef\r\na b c\nMgen123abc"
  ---|------ - ------ ----------

 Output:
 Move to content
 Current char: 'a'
 Line: 1
 Column: 4
 Index(without newline): 3
 Index: 3

 */

console.log('Read until "e"');
console.log('Result -> %s', reader.collectWhile((c) => {
  return c != 'e';
}));
printInfo(reader);
/*
 Reader position:
 "   abcdef\r\na b c\nMgen123abc"
  ---====|-- - ------ ----------

 Output:
 Read until 'e'
 Result -> abcd
 Current char: "e"
 Line: 1
 Column: 8
 Index(without newline): 7
 Index: 7
 */

console.log('Get remaining characters in current line');
console.log('Result -> %s', reader.collectLine());
printInfo(reader);
/*
 Reader position:
 "   abcdef\r\na b c\nMgen123abc"
  -------==- - |----- ----------

 Output:
 Get remaining characters in current line
 Result -> ef
 Current char: 'a'
 Line: 2
 Column: 1
 Index(without newline): 9
 Index: 11

 */

console.log('Skip the whole line');
reader.skipLine();
printInfo(reader);
/*
 Reader position:
 "   abcdef\r\na b c\nMgen123abc"
  ---------- - ------ |---------

 Output:
 Skip the whole line
 Current char: 'M'
 Line: 3
 Column: 1
 Index(without newline): 14
 Index: 17

 */

console.log('Skip to first number');
reader.skipWhile((c) => {
  return isNaN(c);
});
printInfo(reader);
/*
 Reader position:
 "   abcdef\r\na b c\nMgen123abc"
  ---------- - ------ ----|-----

 Output:
 Skip to first number
 Current char: '1'
 Line: 3
 Column: 5
 Index(without newline): 18
 Index: 21

 */

console.log('Read all numbers');
console.log(reader.collectWhile(function (c) {
  return !isNaN(c);
}));
printInfo(reader);
/*
 Reader position:
 "   abcdef\r\na b c\nMgen123abc"
  ---------------------------|--

 Output:
 Read all numbers
 123
 Current char: 'a'
 Line: 3
 Column: 8
 Index(without newline): 21
 Index: 24

 */

console.log('Read to end using mark and collect');
reader.mark();
while (reader.hasNext()) {
  reader.next();
}
console.log('Result -> %s', reader.collect());
/*
 Reader position:
 "   abcdef\r\na b c\nMgen123abc"
  ---------------------------===

 Output:
 Result -> abc

 */

function printInfo(reader) {
  var curChar;
  if (reader.hasNext()) {
    curChar = reader.peek();
  } else {
    curChar = 'End of string';
  }
  console.log("Current char: '%s'\nLine: %d\nColumn: %d\nIndex(without newline): %d\nIndex: %d\n",
    curChar,
    reader.lineIndex + 1,
    reader.columnIndex + 1,
    reader.visibleIndex,
    reader.index);
}

License

MIT