mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #4158 from hansrwindhoff/master
typing for Arbitrary Delimiters
This commit is contained in:
Vendored
+17
@@ -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
|
||||
|
||||
@@ -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));
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Type definitions for uniq
|
||||
// Project: https://www.npmjs.com/package/uniq
|
||||
// Definitions by: Hans Windhoff <https://github.com/hansrwindhoff>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
interface Uniq{
|
||||
<T>(ip:Array<T>): Array<T>;
|
||||
}
|
||||
|
||||
declare var uniq :Uniq;
|
||||
|
||||
declare module "uniq" {
|
||||
export = uniq;
|
||||
}
|
||||
Reference in New Issue
Block a user