0.1.10 • Published 7 years ago
@pg-english/token v0.1.10
@pg-english/token
Define, parse or stringify tokens.
const token = require('@pg-english/token');
// token([type], [value], [hint])
// token.type: {TEXT, NORMAL, QUOTED, ...}
// token.parse(<text>)
// token.toString(<tokens>)
// ...
const T = token.type;
token(T.TEXT, 'forty');
// {type: 16, value: 'forty'}
var tokens = token.parse('food with highest calcium');
// [ { type: 16, value: 'food' },
// { type: 16, value: 'with' },
// { type: 16, value: 'highest' },
// { type: 16, value: 'calcium' } ]
token.toString(tokens)
// food with highest calcium