From 08ae0b1793b5ba7486b7df46d97908c053caa5fd Mon Sep 17 00:00:00 2001 From: hansrwindhoff Date: Mon, 20 Apr 2015 11:32:59 -0600 Subject: [PATCH 1/2] typing for Arbitrary Delimiters https://github.com/mbostock/d3/wiki/CSV#arbitrary-delimiters --- d3/d3.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index b71610f94..f3dbee63d 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -371,6 +371,12 @@ declare module D3 { * Request a comma-separated values (CSV) file. */ csv: Dsv; + + /** + * Request an arbitrary char-separated values file parser, like semicolon or what ever + */ + dsv: Dsv; + /** * Request a tab-separated values (TSV) file */ @@ -708,6 +714,17 @@ declare module D3 { */ (url: string, callback?: (error: any, response: any[]) => void ): Xhr; /** + * Arbitrary Delimiters: + * Constructs a new parser for the given delimiter and mime type. For example, to parse values separated by "|", the vertical bar character, use: + * var dsv = d3.dsv("|", "text/plain"); + * + * returns the new parser + * + * @param separator seperator character + * @param contentType + */ + (separator: string, contentType:string): (url: string, callback?: (error: any, response: any[]) => void )=> Xhr; + /** * Parse a delimited string into objects using the header row. * * @param string delimited formatted string to parse From 058e1f9054d89f7bf31da3e98dc486f7f2a38739 Mon Sep 17 00:00:00 2001 From: hansrwindhoff Date: Mon, 20 Apr 2015 17:30:50 -0600 Subject: [PATCH 2/2] https://www.npmjs.com/package/uniq --- uniq/uniq-tests.ts | 7 +++++++ uniq/uniq.d.ts | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 uniq/uniq-tests.ts create mode 100644 uniq/uniq.d.ts diff --git a/uniq/uniq-tests.ts b/uniq/uniq-tests.ts new file mode 100644 index 000000000..b9facc8e2 --- /dev/null +++ b/uniq/uniq-tests.ts @@ -0,0 +1,7 @@ +import unique = require("uniq"); +var data = [1, 2, 2, 3, 4, 5, 5, 5, 6]; +var datastr = ["1", "2", "2", "3", "4", "5", "5", "5", "6"]; +var dataMix = ["1", 2,"2", {"2":2}, "3", "4", "5", "5", "5", "6"]; +console.log(unique(data)); +console.log(unique(datastr)); +console.log(unique(dataMix)); diff --git a/uniq/uniq.d.ts b/uniq/uniq.d.ts new file mode 100644 index 000000000..f682262c9 --- /dev/null +++ b/uniq/uniq.d.ts @@ -0,0 +1,15 @@ +// Type definitions for uniq +// Project: https://www.npmjs.com/package/uniq +// Definitions by: Hans Windhoff +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface Uniq{ + (ip:Array): Array; +} + +declare var uniq :Uniq; + +declare module "uniq" { +export = uniq; +}