mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-16 11:02:11 +08:00
Merge pull request #8811 from RomanGolovanov/master
added definitions for windows-1251
This commit is contained in:
21
windows-1251/windows-1251-tests.ts
Normal file
21
windows-1251/windows-1251-tests.ts
Normal 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
26
windows-1251/windows-1251.d.ts
vendored
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user