Skip to content

Converts a stream of strings into stream of tokens splitted by delimiters

License

Notifications You must be signed in to change notification settings

Schmidt-DevOps/tokenizer

 
 

Repository files navigation

Dart Tokenizer

Dart

Converts a stream of strings into a stream of tokens separated by delimiters.

Installation

pubspec.yaml:

dependencies:
  tokenizer: ^0.0.1

or

pub global activate tokenizer

Example

import 'dart:async';

import 'package:tokenizer/tokenizer.dart';

void main(List<String> args) async {
  final string = 'Hello, world';
  final tokenizer = Tokenizer({','});
  final c = StreamController<String>();

  c.add(string);
  c.close();

  final tokens = await c.stream.transform(tokenizer.streamTransformer).toList();
  print(tokens); // [Token("Hello"), Token(","), Token(" "), Token("world")]
}

License

MIT

About

Converts a stream of strings into stream of tokens splitted by delimiters

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 100.0%