mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-08 16:40:30 +08:00
Type definition and tests for node cson module
This commit is contained in:
@@ -0,0 +1 @@
|
||||
hello: 'world'
|
||||
@@ -0,0 +1 @@
|
||||
{"hello": "world"}
|
||||
@@ -0,0 +1,36 @@
|
||||
/// <reference path="cson.d.ts" />
|
||||
|
||||
import cson = require('cson');
|
||||
|
||||
var data: string = cson.stringify({hello: 'world'});
|
||||
console.log('cson.stringify => %s', data);
|
||||
|
||||
data = cson.createString({hello: 'world'});
|
||||
console.log('cson.createString => %s', data);
|
||||
|
||||
data = cson.createJSONString({hello: 'world'});
|
||||
console.log('cson.createJSONString => %s', data);
|
||||
|
||||
data = cson.createCSONString({hello: 'world'});
|
||||
console.log('cson.createCSONString => %s', data);
|
||||
|
||||
var obj: Object = cson.parse(data);
|
||||
console.log('cson.parse => %s', JSON.stringify(obj));
|
||||
|
||||
obj = cson.parseCSONString(data);
|
||||
console.log('cson.parseCSONString => %s', JSON.stringify(obj));
|
||||
|
||||
obj = cson.parseJSONString('{"hello": "world"}');
|
||||
console.log('cson.parseJSONString => %s', JSON.stringify(obj));
|
||||
|
||||
obj = cson.parseString("hello: 'world'");
|
||||
console.log('cson.parseString => %s', JSON.stringify(obj));
|
||||
|
||||
obj = cson.load('cson-test.cson');
|
||||
console.log('cson.load => %s', JSON.stringify(obj));
|
||||
|
||||
obj = cson.parseCSONFile('cson-test.cson');
|
||||
console.log('cson.parseCSONFile => %s', JSON.stringify(obj));
|
||||
|
||||
obj = cson.parseJSONFile('cson-test.json');
|
||||
console.log('cson.parseJSONFile => %s', JSON.stringify(obj));
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// Type definitions for CSON
|
||||
// Project: https://github.com/bevry/cson
|
||||
// Definitions by: Sam Saint-Pettersen <https://github.com/stpettersens>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "cson" {
|
||||
// Create Strings
|
||||
export function stringify(data: Object, opts?: Object, indent?: any): string;
|
||||
export function createCSONString(data: Object, opts?: Object, next?: any): string;
|
||||
export function createJSONString(data: Object, opts?: Object, next?: any): string;
|
||||
export function createString(data: Object, opts?: Object, next?: any): string;
|
||||
|
||||
// Parse Strings
|
||||
export function parse(data: string, opts?: Object, next?: any): Object;
|
||||
export function parseCSONString(data: string, opts?: Object, next?: any): Object;
|
||||
export function parseJSONString(data: string, opts?: Object, next?: any): Object;
|
||||
export function parseCSString(data: string, opts?: Object, next?: any): Object;
|
||||
export function parseJSString(data: string, opts?: Object, next?: any): Object;
|
||||
export function parseString(data: string, opts?: Object, next?:any): Object;
|
||||
|
||||
// Parse Files
|
||||
export function load(filePath: string, opts?: Object, next?: any): Object;
|
||||
export function parseCSONFile(filePath: string, opts?: Object, next?: any): Object;
|
||||
export function parseJSONFile(filePath: string, opts?: Object, next?: any): Object;
|
||||
export function parseCSFile(filePath: string, opts?: Object, next?: any): Object;
|
||||
export function parseJSFile(filePath: string, opts?: Object, next?: any): Object;
|
||||
|
||||
// Require Files
|
||||
export function requireCSFile(filePath: string, opts?: Object, next?: any): Object;
|
||||
export function requireJSFile(filePath: string, opts?: Object, next?: any): Object;
|
||||
export function requireFile(filePath: string, opts?: Object, next?: any): Object;
|
||||
}
|
||||
Reference in New Issue
Block a user