Merge pull request #8811 from RomanGolovanov/master

added definitions for windows-1251
This commit is contained in:
Masahiro Wakame
2016-04-06 00:57:18 +09:00
2 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
/// <reference path='windows-1251.d.ts' />
import * as windows1251 from 'windows-1251';
var text:string = "some text", byteString:string, decodedText:string;
var version:string = windows1251.version;
var labels:string[] = windows1251.labels;
byteString = windows1251.encode(text);
byteString = windows1251.encode(text, { mode: 'html' });
byteString = windows1251.encode(text, { mode: 'fatal' });
decodedText = windows1251.decode(byteString);
decodedText = windows1251.decode(byteString, { mode: 'fatal' });
decodedText = windows1251.decode(byteString, { mode: 'replacement' });

26
windows-1251/windows-1251.d.ts vendored Normal file
View File

@@ -0,0 +1,26 @@
// Type definitions for windows-1251 v0.1.2
// Project: https://github.com/mathiasbynens/windows-1251
// Definitions by: RomanGolovanov <https://github.com/RomanGolovanov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace windows1251 {
type EncoderMode = 'fatal' | 'html';
type DecoderMode = 'replacement' | 'fatal';
interface windows1251 {
encode(input:string, options?:{ mode?: EncoderMode }):string;
decode(text: string, options?:{ mode?: DecoderMode }): string;
}
}
declare module 'windows-1251' {
var windows1251: {
encode(input:string, options?:{ mode?: windows1251.EncoderMode }):string;
decode(text: string, options?:{ mode?: windows1251.DecoderMode }): string;
version: string;
labels: string[];
}
export = windows1251;
}