@k14v/printf-tokenize
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

printf-tokenize

Javascript printf tokenize creates a array of tokens using the standard from cplusplus http://www.cplusplus.com/reference/cstdio/printf/ to parse flags.

const tokenize = require('@k14v/printf-tokenize')

tokenize('This is %s test with %d flags')

/*
[ { type: 'Literal', value: 'This is ', start: 0, end: 8, length: 8 },
  { type: 'Parameter',
    value: '%s',
    start: 8,
    end: 10,
    length: 2,
    kind: 'String',
    specifier: 's' },
  { type: 'Literal',
    value: ' test with ',
    start: 10,
    end: 21,
    length: 11 },
  { type: 'Parameter',
    value: '%d',
    start: 21,
    end: 23,
    length: 2,
    kind: 'Number',
    specifier: 'd',
    variant: 'Integer' },
  { type: 'Literal', value: ' flags', start: 23, end: 29, length: 6 } ]
*/

/@k14v/printf-tokenize/

    Package Sidebar

    Install

    npm i @k14v/printf-tokenize

    Weekly Downloads

    9

    Version

    0.0.6

    License

    MIT

    Unpacked Size

    26.1 kB

    Total Files

    6

    Last publish

    Collaborators

    • rubeniskov
    • kelvur