##// END OF EJS Templates
added provided and configure methods to the fluent container configuration, added applyConfig method to the container
added provided and configure methods to the fluent container configuration, added applyConfig method to the container

File last commit:

r115:691199f665e0 ioc ts support
r142:be7edf08a115 v1.4.0-rc3 default
Show More
FormatScanner.ts
54 lines | 1.3 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / text / FormatScanner.ts
import { argumentNotEmptyString } from "../safe";
import { MapOf } from "../interfaces";
export const enum TokeType {
CurlOpen = 1,
CurlClose = 2,
Colon = 3,
Text = 4
}
const typeMap = {
"{": TokeType.CurlOpen,
"}": TokeType.CurlClose,
":": TokeType.Colon
} as MapOf<TokeType>;
export class FormatScanner {
private _text: string;
private _tokenType: TokeType | undefined;
private _tokenValue: string | undefined;
private _rx = /[^{}:]+|(.)/g;
constructor(text: string) {
argumentNotEmptyString(text, text);
this._text = text;
}
next() {
if (this._rx.lastIndex >= this._text.length)
return false;
const match = this._rx.exec(this._text);
if (match === null)
return false;
this._tokenType = typeMap[match[1]] || TokeType.Text;
this._tokenValue = match[0];
return true;
}
getTokenValue() {
if (this._tokenValue === undefined)
throw new Error("The scanner is before the first element");
return this._tokenValue;
}
getTokenType() {
if (this._tokenType === undefined)
throw new Error("The scanner is before the first element");
return this._tokenType;
}
}