diff --git a/types/pull-stream/index.d.ts b/types/pull-stream/index.d.ts new file mode 100644 index 0000000000..22d43bc1cc --- /dev/null +++ b/types/pull-stream/index.d.ts @@ -0,0 +1,147 @@ +// Type definitions for pull-stream 3.6 +// Project: https://pull-stream.github.io +// Definitions by: Michael de Wit +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.4 + +import { count as countImport, empty as emptyImport, error as errorImport, infinite as infiniteImport, keys as keysImport, once as onceImport, values as valuesImport } from './sources'; +import { + asyncMap as asyncMapImport, + filterNot as filterNotImport, + filter as filterImport, + flatten as flattenImport, + map as mapImport, + nonUnique as nonUniqueImport, + take as takeImport, + through as throughImport, + unique as uniqueImport +} from './throughs'; +import { collect as collectImport, concat as concatImport, drain as drainImport, find as findImport, log as logImport, onEnd as onEndImport, reduce as reduceImport } from './sinks'; + +/** + * Pipe data through a number of `pull-stream`s + */ +declare function pull(): undefined; +declare function pull(source: pull.Source, sink: pull.Sink): undefined; +declare function pull(source: pull.Source, t1: pull.Through, sink: pull.Sink): undefined; +declare function pull(source: pull.Source, t1: pull.Through, t2: pull.Through, sink: pull.Sink): undefined; +declare function pull(source: pull.Source, t1: pull.Through, t2: pull.Through, t3: pull.Through, sink: pull.Sink): undefined; +declare function pull( + source: pull.Source, + t1: pull.Through, + t2: pull.Through, + t3: pull.Through, + t4: pull.Through, + sink: pull.Sink +): undefined; +declare function pull( + source: pull.Source, + t1: pull.Through, + t2: pull.Through, + t3: pull.Through, + t4: pull.Through, + t5: pull.Through, + sink: pull.Sink +): undefined; + +declare function pull(sink: pull.Sink): pull.Sink; +declare function pull(t1: pull.Through, sink: pull.Sink): pull.Sink; +declare function pull(t1: pull.Through, t2: pull.Through, sink: pull.Sink): pull.Sink; +declare function pull(t1: pull.Through, t2: pull.Through, t3: pull.Through, sink: pull.Sink): pull.Sink; +declare function pull(t1: pull.Through, t2: pull.Through, t3: pull.Through, t4: pull.Through, sink: pull.Sink): pull.Sink; +declare function pull( + t1: pull.Through, + t2: pull.Through, + t3: pull.Through, + t4: pull.Through, + t5: pull.Through, + sink: pull.Sink +): pull.Sink; +declare function pull( + t1: pull.Through, + t2: pull.Through, + t3: pull.Through, + t4: pull.Through, + t5: pull.Through, + t6: pull.Through, + sink: pull.Sink +): pull.Sink; + +declare function pull(source: pull.Source): pull.Source; +declare function pull(source: pull.Source, t1: pull.Through): pull.Source; +declare function pull(source: pull.Source, t1: pull.Through, t2: pull.Through): pull.Source; +declare function pull(source: pull.Source, t1: pull.Through, t2: pull.Through, t3: pull.Through): pull.Source; +declare function pull(source: pull.Source, t1: pull.Through, t2: pull.Through, t3: pull.Through, t4: pull.Through): pull.Source; +declare function pull( + source: pull.Source, + t1: pull.Through, + t2: pull.Through, + t3: pull.Through, + t4: pull.Through, + t5: pull.Through +): pull.Source; +declare function pull( + source: pull.Source, + t1: pull.Through, + t2: pull.Through, + t3: pull.Through, + t4: pull.Through, + t5: pull.Through, + t6: pull.Through +): pull.Source; + +declare function pull(t1: pull.Through): pull.Through; +declare function pull(t1: pull.Through, t2: pull.Through): pull.Through; +declare function pull(t1: pull.Through, t2: pull.Through, t3: pull.Through): pull.Through; +declare function pull(t1: pull.Through, t2: pull.Through, t3: pull.Through, t4: pull.Through): pull.Through; +declare function pull( + t1: pull.Through, + t2: pull.Through, + t3: pull.Through, + t4: pull.Through, + t5: pull.Through +): pull.Through; +declare function pull( + t1: pull.Through, + t2: pull.Through, + t3: pull.Through, + t4: pull.Through, + t5: pull.Through, + t6: pull.Through +): pull.Through; + +declare function pull(...pullStreams: ReadonlyArray<(pull.Source | pull.Sink | pull.Through)>): pull.Source | pull.Sink | pull.Through | undefined; + +declare namespace pull { + type Source = (endOrError: Error | boolean | null, cb: (endOrError: Error | boolean | null, data: T) => any) => undefined; + type Sink = (source: Source) => undefined; + type Through = (source: Source) => Source; + + const count: typeof countImport; + const empty: typeof emptyImport; + const error: typeof errorImport; + const infinite: typeof infiniteImport; + const keys: typeof keysImport; + const once: typeof onceImport; + const values: typeof valuesImport; + + const asyncMap: typeof asyncMapImport; + const filterNot: typeof filterNotImport; + const filter: typeof filterImport; + const flatten: typeof flattenImport; + const map: typeof mapImport; + const nonUnique: typeof nonUniqueImport; + const take: typeof takeImport; + const through: typeof throughImport; + const unique: typeof uniqueImport; + + const collect: typeof collectImport; + const concat: typeof concatImport; + const drain: typeof drainImport; + const find: typeof findImport; + const log: typeof logImport; + const onEnd: typeof onEndImport; + const reduce: typeof reduceImport; +} + +export = pull; diff --git a/types/pull-stream/pull-stream-tests.ts b/types/pull-stream/pull-stream-tests.ts new file mode 100644 index 0000000000..99f7acc7e0 --- /dev/null +++ b/types/pull-stream/pull-stream-tests.ts @@ -0,0 +1,167 @@ +import pull = require('pull-stream'); + +/******** + * pull * + ********/ + +let source: pull.Source = (end, cb) => undefined; +let through: pull.Through = (source) => source; +let sink: pull.Sink = (source) => undefined; + +// Start with source and end with sink +let nothing: undefined; +nothing = pull(); +nothing = pull(source, sink); +nothing = pull(source, through, sink); +nothing = pull(source, through, through, sink); + +// End with sink +sink = pull(sink); +sink = pull(through, sink); +sink = pull(through, through, sink); + +// Start with source +source = pull(source); +source = pull(source, through); +source = pull(source, through, through); + +// Through only +through = pull(through); +through = pull(through, through); +through = pull(through, through, through); + +const numberSource: pull.Source = (end, cb) => undefined; +const parseNumber: pull.Through = (source) => numberSource; +const numberSink: pull.Sink = (source) => undefined; + +// Strictly typed pipe +nothing = pull(source, through, parseNumber, numberSink); + +// Long pipe +let result: pull.Source | pull.Sink | pull.Through | undefined; +result = pull(source, through, through, through, through, through, through, through, through, sink); + +/*********** + * sources * + ***********/ + +// count +nothing = pull(pull.count(), numberSink); +nothing = pull(pull.count(5), numberSink); +nothing = pull(pull.count(5, (err) => { if (err) err.stack; }), numberSink); + +// empty +nothing = pull(pull.empty(), sink); + +// error +nothing = pull(pull.error(), sink); + +// infinite +nothing = pull(pull.infinite(), numberSink); +nothing = pull(pull.infinite(() => 'value'), sink); +nothing = pull(pull.infinite(() => 'value', (err) => { if (err) err.stack; }), sink); + +// keys +nothing = pull(pull.keys({ hello: 'world' }), sink); +nothing = pull(pull.keys([]), sink); +nothing = pull(pull.keys([], (err) => { if (err) err.stack; }), sink); + +// once +nothing = pull(pull.once('value'), sink); +nothing = pull(pull.once(1), numberSink); +nothing = pull(pull.once(1, (err) => { if (err) err.stack; }), numberSink); + +// values +nothing = pull(pull.values(['hello', 'world']), sink); +nothing = pull(pull.values([1, 2]), numberSink); +nothing = pull(pull.values([1, 2], (err) => { if (err) err.stack; }), numberSink); + +/************ + * throughs * + ************/ + +// asyncMap +nothing = pull(source, pull.asyncMap((data, cb) => { cb(null, Number(data)); }), numberSink); + +// filterNot +nothing = pull(source, pull.filterNot((data) => data === 'hello'), sink); + +// filter +nothing = pull(source, pull.filter((data) => data === 'hello'), sink); +nothing = pull(source, pull.filter((data): data is 'hello' => data === 'hello'), sink as pull.Sink<'hello'>); + +// flatten +const streamOfArrays: pull.Source = (end, cb) => undefined; +const streamOfStreams: pull.Source>> = (end, cb) => undefined; +const throughToStreams: pull.Through< + any, + Array> +> = streamOfStreams => streamOfStreams; +nothing = pull(streamOfArrays, pull.flatten(), sink); +nothing = pull(streamOfStreams, pull.flatten(), sink); +sink = pull(throughToStreams, pull.flatten(), sink); + +// map +nothing = pull(source, pull.map(Number), numberSink); + +// nonUnique +nothing = pull(source, pull.nonUnique(), sink); +nothing = pull(source, pull.nonUnique(Number), sink); +nothing = pull(source, pull.nonUnique('length'), sink); + +// take +nothing = pull(source, pull.take(1), sink); +nothing = pull(source, pull.take(s => !!s), sink); +nothing = pull(source, pull.take(s => !!s, { last: true }), sink); + +// through +nothing = pull(source, pull.through(), sink); +nothing = pull(source, pull.through(Number), sink); +nothing = pull(source, pull.through(Number, (err) => { if (err) err.stack; }), sink); + +// unique +nothing = pull(source, pull.unique(), sink); +nothing = pull(source, pull.unique(Number), sink); +nothing = pull(source, pull.unique('length'), sink); + +/********* + * sinks * + *********/ + +// collect +nothing = pull(source, pull.collect((err, results) => { + if (err) err.stack; + const check: string[] = results; +})); + +// concat +nothing = pull(source, pull.concat((err, result) => { + if (err) err.stack; + const check: string = result; +})); + +// drain +nothing = pull(source, pull.drain(Number)); +nothing = pull(source, pull.drain(Number, (err) => { if (err) err.stack; })); + +// find +nothing = pull(source, pull.find()); +nothing = pull(source, pull.find((err) => { if (err) err.stack; })); +nothing = pull(source, pull.find(Boolean, (err) => { if (err) err.stack; })); +nothing = pull(source, pull.find('length', (err) => { if (err) err.stack; })); + +// log +nothing = pull(source, pull.log()); + +// onEnd +nothing = pull(source, pull.onEnd((err) => { if (err) err.stack; })); + +// reduce +nothing = pull(source, pull.reduce((acc, data) => (acc || 0) + Number(data), (err, result) => { + if (err) err.stack; + const check: number = result; +})); +nothing = pull(source, pull.reduce((acc, data) => acc + Number(data), 0, (err, result) => { + if (err) err.stack; + const check: number = result; +})); diff --git a/types/pull-stream/sinks/collect.d.ts b/types/pull-stream/sinks/collect.d.ts new file mode 100644 index 0000000000..85a3e5a349 --- /dev/null +++ b/types/pull-stream/sinks/collect.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Read the stream into an array, then call `cb`. + */ +declare function collect(cb?: (err: Error | null, results: T[]) => unknown): pull.Sink; +export = collect; diff --git a/types/pull-stream/sinks/concat.d.ts b/types/pull-stream/sinks/concat.d.ts new file mode 100644 index 0000000000..497bccd433 --- /dev/null +++ b/types/pull-stream/sinks/concat.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Concat stream of strings into single string, then call `cb`. + */ +declare function concat(cb?: (err: Error | null, result: string) => unknown): pull.Sink; +export = concat; diff --git a/types/pull-stream/sinks/drain.d.ts b/types/pull-stream/sinks/drain.d.ts new file mode 100644 index 0000000000..788d23cdac --- /dev/null +++ b/types/pull-stream/sinks/drain.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Drain the stream, calling op on each `data`. Call `done` when stream is finished. If `op` returns `=== false`, abort the stream. + */ +declare function drain(op?: (data: T) => unknown, cb?: (err: Error | null) => unknown): pull.Sink; +export = drain; diff --git a/types/pull-stream/sinks/find.d.ts b/types/pull-stream/sinks/find.d.ts new file mode 100644 index 0000000000..7d900d0683 --- /dev/null +++ b/types/pull-stream/sinks/find.d.ts @@ -0,0 +1,5 @@ +import pull = require('..'); + +declare function find(cb?: (err: Error | null, results: T[]) => unknown): pull.Sink; +declare function find(test: ((data: T) => boolean) | keyof T, cb?: (err: Error | null, result: T) => unknown): pull.Sink; +export = find; diff --git a/types/pull-stream/sinks/index.d.ts b/types/pull-stream/sinks/index.d.ts new file mode 100644 index 0000000000..1f9a956e47 --- /dev/null +++ b/types/pull-stream/sinks/index.d.ts @@ -0,0 +1,15 @@ +import collectImport = require('./collect'); +import concatImport = require('./concat'); +import drainImport = require('./drain'); +import findImport = require('./find'); +import logImport = require('./log'); +import onEndImport = require('./on-end'); +import reduceImport = require('./reduce'); + +export const collect: typeof collectImport; +export const concat: typeof concatImport; +export const drain: typeof drainImport; +export const find: typeof findImport; +export const log: typeof logImport; +export const onEnd: typeof onEndImport; +export const reduce: typeof reduceImport; diff --git a/types/pull-stream/sinks/log.d.ts b/types/pull-stream/sinks/log.d.ts new file mode 100644 index 0000000000..1fb464d196 --- /dev/null +++ b/types/pull-stream/sinks/log.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Output the stream to `console.log`. + */ +declare function log(): pull.Sink; +export = log; diff --git a/types/pull-stream/sinks/on-end.d.ts b/types/pull-stream/sinks/on-end.d.ts new file mode 100644 index 0000000000..d7a80f149b --- /dev/null +++ b/types/pull-stream/sinks/on-end.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Drain the stream and then call `cb` when done. + */ +declare function onEnd(cb?: (err: Error | null) => unknown): pull.Sink; +export = onEnd; diff --git a/types/pull-stream/sinks/reduce.d.ts b/types/pull-stream/sinks/reduce.d.ts new file mode 100644 index 0000000000..0f24daf667 --- /dev/null +++ b/types/pull-stream/sinks/reduce.d.ts @@ -0,0 +1,8 @@ +import pull = require('..'); + +/** + * Reduce stream into single value, then callback. + */ +declare function reduce(reducer: (acc: U | null, data: T) => U, cb: (err: Error | null, result: U) => unknown): pull.Sink; +declare function reduce(reducer: (acc: U, data: T) => U, initial: U, cb: (err: Error | null, result: U) => unknown): pull.Sink; +export = reduce; diff --git a/types/pull-stream/sources/count.d.ts b/types/pull-stream/sources/count.d.ts new file mode 100644 index 0000000000..c801893a7c --- /dev/null +++ b/types/pull-stream/sources/count.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Create a stream that outputs 0 ... `max`. By default, `max` = `Infinity`. + */ +declare function count(max?: number, onAbort?: (err?: Error | null) => unknown): pull.Source; +export = count; diff --git a/types/pull-stream/sources/empty.d.ts b/types/pull-stream/sources/empty.d.ts new file mode 100644 index 0000000000..b6627e8b7c --- /dev/null +++ b/types/pull-stream/sources/empty.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Create a stream with no contents (it just ends immediately). + */ +declare function empty(): pull.Source; +export = empty; diff --git a/types/pull-stream/sources/error.d.ts b/types/pull-stream/sources/error.d.ts new file mode 100644 index 0000000000..1dab84a27b --- /dev/null +++ b/types/pull-stream/sources/error.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Create a stream with no contents (it just ends immediately). + */ +declare function error(): pull.Source; +export = error; diff --git a/types/pull-stream/sources/index.d.ts b/types/pull-stream/sources/index.d.ts new file mode 100644 index 0000000000..35a9f9ba2a --- /dev/null +++ b/types/pull-stream/sources/index.d.ts @@ -0,0 +1,15 @@ +import countImport = require('./count'); +import emptyImport = require('./empty'); +import errorImport = require('./error'); +import infiniteImport = require('./infinite'); +import keysImport = require('./keys'); +import onceImport = require('./once'); +import valuesImport = require('./values'); + +export const count: typeof countImport; +export const empty: typeof emptyImport; +export const error: typeof errorImport; +export const infinite: typeof infiniteImport; +export const keys: typeof keysImport; +export const once: typeof onceImport; +export const values: typeof valuesImport; diff --git a/types/pull-stream/sources/infinite.d.ts b/types/pull-stream/sources/infinite.d.ts new file mode 100644 index 0000000000..656c7d4530 --- /dev/null +++ b/types/pull-stream/sources/infinite.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Create an unending stream by repeatedly calling a generator function (by default, `Math.random`). + */ +declare function infinite(generator?: () => T, onAbort?: (err?: Error | null) => unknown): pull.Source; +export = infinite; diff --git a/types/pull-stream/sources/keys.d.ts b/types/pull-stream/sources/keys.d.ts new file mode 100644 index 0000000000..13cb9ee1b1 --- /dev/null +++ b/types/pull-stream/sources/keys.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Stream the key names from an object (or array). + */ +declare function keys(obj: object | ReadonlyArray, onAbort?: (err?: Error | null) => unknown): pull.Source; +export = keys; diff --git a/types/pull-stream/sources/once.d.ts b/types/pull-stream/sources/once.d.ts new file mode 100644 index 0000000000..1e4c44a95f --- /dev/null +++ b/types/pull-stream/sources/once.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Create a stream with a single value. + */ +declare function once(value?: T, onAbort?: (err?: Error | null) => unknown): pull.Source; +export = once; diff --git a/types/pull-stream/sources/values.d.ts b/types/pull-stream/sources/values.d.ts new file mode 100644 index 0000000000..c38532f265 --- /dev/null +++ b/types/pull-stream/sources/values.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Create a SourceStream that reads the values from an array or object and then stops. + */ +declare function values(arrayOrObject?: Record | ReadonlyArray, onAbort?: (err?: Error | null) => unknown): pull.Source; +export = values; diff --git a/types/pull-stream/throughs/async-map.d.ts b/types/pull-stream/throughs/async-map.d.ts new file mode 100644 index 0000000000..c1500efac6 --- /dev/null +++ b/types/pull-stream/throughs/async-map.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Like `map` but the signature of `fn` must be `function (data, cb) { cb(null, data) }`. + */ +declare function asyncMap(fn: (data: In, cb: (err: Error | null, result: Out) => void) => any): pull.Through; +export = asyncMap; diff --git a/types/pull-stream/throughs/filter-not.d.ts b/types/pull-stream/throughs/filter-not.d.ts new file mode 100644 index 0000000000..2891781059 --- /dev/null +++ b/types/pull-stream/throughs/filter-not.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Like `filter`, but remove items where the filter returns true. + */ +declare function filterNot(test: (data: InOut) => boolean): pull.Through; +export = filterNot; diff --git a/types/pull-stream/throughs/filter.d.ts b/types/pull-stream/throughs/filter.d.ts new file mode 100644 index 0000000000..50c2db7a61 --- /dev/null +++ b/types/pull-stream/throughs/filter.d.ts @@ -0,0 +1,8 @@ +import pull = require('..'); + +/** + * Like `[].filter(function (data) {return true || false})` only `data` where `test(data) == true` are let through to the next stream. + */ +declare function filter(test: (data: In) => data is Out): pull.Through; +declare function filter(test: (data: InOut) => boolean): pull.Through; +export = filter; diff --git a/types/pull-stream/throughs/flatten.d.ts b/types/pull-stream/throughs/flatten.d.ts new file mode 100644 index 0000000000..c0f0f0a9f1 --- /dev/null +++ b/types/pull-stream/throughs/flatten.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Turn a stream of streams or a stream of arrays into a stream of their items, (undoes group). + */ +declare function flatten(): pull.Through | pull.Through>, Out>; +export = flatten; diff --git a/types/pull-stream/throughs/index.d.ts b/types/pull-stream/throughs/index.d.ts new file mode 100644 index 0000000000..efad453005 --- /dev/null +++ b/types/pull-stream/throughs/index.d.ts @@ -0,0 +1,19 @@ +import asyncMapImport = require('./async-map'); +import filterNotImport = require('./filter-not'); +import filterImport = require('./filter'); +import flattenImport = require('./flatten'); +import mapImport = require('./map'); +import nonUniqueImport = require('./non-unique'); +import takeImport = require('./take'); +import throughImport = require('./through'); +import uniqueImport = require('./unique'); + +export const asyncMap: typeof asyncMapImport; +export const filterNot: typeof filterNotImport; +export const filter: typeof filterImport; +export const flatten: typeof flattenImport; +export const map: typeof mapImport; +export const nonUnique: typeof nonUniqueImport; +export const take: typeof takeImport; +export const through: typeof throughImport; +export const unique: typeof uniqueImport; diff --git a/types/pull-stream/throughs/map.d.ts b/types/pull-stream/throughs/map.d.ts new file mode 100644 index 0000000000..7560718392 --- /dev/null +++ b/types/pull-stream/throughs/map.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Returns a through stream that calls the given `fn` for each chunk of incoming data and outputs the return value, in the same order as before. + */ +declare function map(fn: (data: In) => Out): pull.Through; +export = map; diff --git a/types/pull-stream/throughs/non-unique.d.ts b/types/pull-stream/throughs/non-unique.d.ts new file mode 100644 index 0000000000..06fc7493f5 --- /dev/null +++ b/types/pull-stream/throughs/non-unique.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Filter unique items -- get the duplicates. The inverse of `unique`. + */ +declare function nonUnique(prop?: ((data: InOut) => unknown) | keyof InOut): pull.Through; +export = nonUnique; diff --git a/types/pull-stream/throughs/take.d.ts b/types/pull-stream/throughs/take.d.ts new file mode 100644 index 0000000000..8b1dafc75e --- /dev/null +++ b/types/pull-stream/throughs/take.d.ts @@ -0,0 +1,12 @@ +import pull = require('..'); + +/** + * `take` has 2 valid signatures: + * 1. A single positive integer `n`. `take` pulls `n` values from the source and then closes the stream. This is really useful for limiting how much you pull. + * 2. A `testFn` function and optional `opts`. Read data from the source stream and forward it downstream until `testFn(data)` returns false, then close the stream. + * + * `opts` is an optional Object of form `{ last: Boolean }`, where `opts.last` determines whether the last value tested (before closing the stream) is included or excluded (default). + */ +declare function take(n: number): pull.Through; +declare function take(testFn: (data: InOut) => boolean, opts?: { last: boolean }): pull.Through; +export = take; diff --git a/types/pull-stream/throughs/through.d.ts b/types/pull-stream/throughs/through.d.ts new file mode 100644 index 0000000000..6da78fe0e9 --- /dev/null +++ b/types/pull-stream/throughs/through.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Returns a pass through stream that doesn't change the value. + */ +declare function through(op?: (data: InOut) => unknown, onEnd?: (err: Error | null) => unknown): pull.Through; +export = through; diff --git a/types/pull-stream/throughs/unique.d.ts b/types/pull-stream/throughs/unique.d.ts new file mode 100644 index 0000000000..3466200763 --- /dev/null +++ b/types/pull-stream/throughs/unique.d.ts @@ -0,0 +1,7 @@ +import pull = require('..'); + +/** + * Filter items that have a repeated value for `prop()`, by default, `prop = function (it) {return it }`, if `prop` is a string, it will filter nodes which have repeated values for that property. + */ +declare function unique(prop?: ((data: InOut) => unknown) | keyof InOut): pull.Through; +export = unique; diff --git a/types/pull-stream/tsconfig.json b/types/pull-stream/tsconfig.json new file mode 100644 index 0000000000..5ca6061f28 --- /dev/null +++ b/types/pull-stream/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "pull-stream-tests.ts" + ] +} diff --git a/types/pull-stream/tslint.json b/types/pull-stream/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pull-stream/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }