UNPKG

ractive

Version:

Next-generation DOM manipulation

18 lines (13 loc) 412 B
import types from 'config/types'; // bulletproof number regex from https://gist.github.com/Rich-Harris/7544330 var numberPattern = /^(?:[+-]?)(?:(?:(?:0|[1-9]\d*)?\.\d+)|(?:(?:0|[1-9]\d*)\.)|(?:0|[1-9]\d*))(?:[eE][+-]?\d+)?/; export default function ( parser ) { var result; if ( result = parser.matchPattern( numberPattern ) ) { return { t: types.NUMBER_LITERAL, v: result }; } return null; }