sscanf

0.8.0 • Public • Published

node-sscanf NPM Version Build Status

C like sscanf for Node.js.

Format support now

  • %d - integer
  • %f - float
  • %s - string
  • %S - string of line
  • %x - hex
  • %o - octal

Return

Directly return

var sscanf = require('sscanf');
 
var number = sscanf('a=2015', 'a=%d');
 
console.log(number); // 2015

Array return

var scanf = require('scanf');
 
var result = scanf('Alan 24 180', '%s%d%d');
 
console.log(result); // [ 'Alan', 24, 180 ]

Json return

var scanf = require('scanf');
 
var result = scanf(
  '12 3.1415926 hello 1F 10',
  '%d %f %s %x %o',
  'integer', 'float', 'string', 'hex', 'octal');
 
console.log(result);
/*  
  integer: 12,
  float: 3.1415926,
  string: 'hello',
  hex: 31,
  octal: 8 
}
*/

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i sscanf

Weekly Downloads

43

Version

0.8.0

License

MIT

Last publish

Collaborators

  • lellansin