mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Merge branch 'master' into dt-cleanup-2019-part-3
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
// near copy of each of the tests from https://github.com/nodeca/argparse/tree/master/examples
|
||||
|
||||
import { ArgumentParser, RawDescriptionHelpFormatter } from 'argparse';
|
||||
import {
|
||||
ArgumentParser,
|
||||
RawDescriptionHelpFormatter,
|
||||
Action,
|
||||
ActionConstructorOptions,
|
||||
Namespace,
|
||||
} from 'argparse';
|
||||
let args: any;
|
||||
|
||||
const simpleExample = new ArgumentParser({
|
||||
@@ -276,3 +282,26 @@ group.addArgument(['--bar'], {
|
||||
help: 'bar help'
|
||||
});
|
||||
formatterExample.printHelp();
|
||||
|
||||
class CustomAction1 extends Action {
|
||||
constructor(options: ActionConstructorOptions) {
|
||||
super(options);
|
||||
}
|
||||
call(parser: ArgumentParser, namespace: Namespace, values: string | string[], optionString: string | null) {
|
||||
console.log('custom action 1');
|
||||
}
|
||||
}
|
||||
|
||||
class CustomAction2 extends Action {
|
||||
call(parser: ArgumentParser, namespace: Namespace, values: string | string[], optionString: string | null) {
|
||||
console.log('custom action 2');
|
||||
}
|
||||
}
|
||||
|
||||
const customActionExample = new ArgumentParser({ addHelp: false });
|
||||
customActionExample.addArgument('--abc', {
|
||||
action: CustomAction1,
|
||||
});
|
||||
customActionExample.addArgument('--def', {
|
||||
action: CustomAction2,
|
||||
});
|
||||
|
||||
Vendored
+13
-1
@@ -3,6 +3,7 @@
|
||||
// Definitions by: Andrew Schurman <https://github.com/arcticwaters>
|
||||
// Tomasz Łaziuk <https://github.com/tlaziuk>
|
||||
// Sebastian Silbermann <https://github.com/eps1lon>
|
||||
// Kannan Goundan <https://github.com/cakoose>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@@ -79,13 +80,24 @@ export interface ArgumentGroupOptions {
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export abstract class Action {
|
||||
protected dest: string;
|
||||
constructor(options: ActionConstructorOptions);
|
||||
abstract call(parser: ArgumentParser, namespace: Namespace, values: string | string[], optionString: string | null): void;
|
||||
}
|
||||
|
||||
// Passed to the Action constructor. Subclasses are just expected to relay this to
|
||||
// the super() constructor, so using an "opaque type" pattern is probably fine.
|
||||
// Someone may want to fill this out in the future.
|
||||
export type ActionConstructorOptions = number & {_: 'ActionConstructorOptions'};
|
||||
|
||||
export class HelpFormatter { }
|
||||
export class ArgumentDefaultsHelpFormatter { }
|
||||
export class RawDescriptionHelpFormatter { }
|
||||
export class RawTextHelpFormatter { }
|
||||
|
||||
export interface ArgumentOptions {
|
||||
action?: string;
|
||||
action?: string | { new(options: ActionConstructorOptions): Action };
|
||||
optionStrings?: string[];
|
||||
dest?: string;
|
||||
nargs?: string | number;
|
||||
|
||||
@@ -21,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"argparse-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import * as bitTwiddle from "bit-twiddle";
|
||||
|
||||
bitTwiddle.INT_BITS;
|
||||
bitTwiddle.INT_MAX;
|
||||
bitTwiddle.INT_MIN;
|
||||
|
||||
bitTwiddle.sign(5);
|
||||
bitTwiddle.abs(-5);
|
||||
bitTwiddle.min(1, 6);
|
||||
bitTwiddle.max(6, 1);
|
||||
bitTwiddle.isPow2(3);
|
||||
bitTwiddle.log2(3);
|
||||
bitTwiddle.log10(3);
|
||||
bitTwiddle.popCount(4);
|
||||
bitTwiddle.countTrailingZeros(3.0000003);
|
||||
bitTwiddle.nextPow2(31.315);
|
||||
bitTwiddle.prevPow2(31.315);
|
||||
bitTwiddle.parity(123);
|
||||
bitTwiddle.interleave2(12, 24);
|
||||
bitTwiddle.deinterleave2(24, 12);
|
||||
bitTwiddle.interleave3(24, 12, 6);
|
||||
bitTwiddle.deinterleave3(24, 12);
|
||||
bitTwiddle.nextCombination(41.935);
|
||||
Vendored
+101
@@ -0,0 +1,101 @@
|
||||
// Type definitions for bit-twiddle 1.0
|
||||
// Project: https://github.com/mikolalysenko/bit-twiddle
|
||||
// Definitions by: Adam Zerella <https://github.com/adamzerella>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.3
|
||||
|
||||
export const INT_BITS: number;
|
||||
export const INT_MAX: number;
|
||||
export const INT_MIN: number;
|
||||
|
||||
/**
|
||||
* Computes the sign of the integer.
|
||||
*/
|
||||
export function sign(value: number): number;
|
||||
|
||||
/**
|
||||
* Returns the absolute value of the integer.
|
||||
*/
|
||||
export function abs(value: number): number;
|
||||
|
||||
/**
|
||||
* Computes the minimum of integers x and y.
|
||||
*/
|
||||
export function min(x: number, y: number): number;
|
||||
|
||||
/**
|
||||
* Computes the maximum of integers x and y.
|
||||
*/
|
||||
export function max(x: number, y: number): number;
|
||||
|
||||
/**
|
||||
* Returns true if value is a power of 2, otherwise false.
|
||||
*/
|
||||
export function isPow2(value: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns an integer approximation of the log-base 2 of value.
|
||||
*/
|
||||
export function log2(value: number): number;
|
||||
|
||||
/**
|
||||
* Returns an integer approximation of the log-base 10 of value.
|
||||
*/
|
||||
export function log10(value: number): number;
|
||||
|
||||
/**
|
||||
* Counts the number of bits set in value.
|
||||
*/
|
||||
export function popCount(value: number): number;
|
||||
|
||||
/**
|
||||
* Counts the number of trailing zeros.
|
||||
*/
|
||||
export function countTrailingZeros(value: number): number;
|
||||
|
||||
/**
|
||||
* Rounds value up to the next power of 2.
|
||||
*/
|
||||
export function nextPow2(value: number): number;
|
||||
|
||||
/**
|
||||
* Rounds value down to the previous power of 2.
|
||||
*/
|
||||
export function prevPow2(value: number): number;
|
||||
|
||||
/**
|
||||
* Computes the parity of the bits in value.
|
||||
*/
|
||||
export function parity(value: number): number;
|
||||
|
||||
/**
|
||||
* Reverses the bits of value.
|
||||
*/
|
||||
export function reverse(value: number): number;
|
||||
|
||||
/**
|
||||
* Interleaves a pair of 16 bit integers. Useful for fast quadtree style indexing.
|
||||
* @see http://en.wikipedia.org/wiki/Z-order_curve
|
||||
*/
|
||||
export function interleave2(x: number, y: number): number;
|
||||
|
||||
/**
|
||||
* Deinterleaves the bits of value, returns the nth part.
|
||||
* If both x and y are 16 bit.
|
||||
*/
|
||||
export function deinterleave2(x: number, y: number): number;
|
||||
|
||||
/**
|
||||
* Interleaves a triple of 10 bit integers. Useful for fast octree indexing.
|
||||
*/
|
||||
export function interleave3(x: number, y: number, z: number): number;
|
||||
|
||||
/**
|
||||
* Same deal as deinterleave2, only for triples instead of pairs.
|
||||
*/
|
||||
export function deinterleave3(x: number, y: number): number;
|
||||
|
||||
/**
|
||||
* Returns next combination ordered colexicographically.
|
||||
*/
|
||||
export function nextCombination(x: number): number;
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [
|
||||
|
||||
],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"bit-twiddle-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for emojione 2.2
|
||||
// Project: https://github.com/Ranks/emojione, http://www.emojione.com
|
||||
// Project: https://github.com/Ranks/emojione, https://www.emojione.com
|
||||
// Definitions by: Danilo Bargen <https://github.com/dbrgn>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
@@ -412,6 +412,7 @@ async () => {
|
||||
{ resize: { width: 300 } },
|
||||
{ resize: { height: 300 } },
|
||||
{ resize: { height: 300, width: 300 } },
|
||||
{ crop: { originX: 0, originY: 0, height: 300, width: 300 } }
|
||||
], {
|
||||
compress: 0.75
|
||||
});
|
||||
|
||||
Vendored
+7
-5
@@ -1952,14 +1952,16 @@ export namespace ImageManipulator {
|
||||
}
|
||||
|
||||
interface Flip {
|
||||
flip?: { vertical?: boolean; horizontal?: boolean };
|
||||
flip: { vertical?: boolean; horizontal?: boolean };
|
||||
}
|
||||
|
||||
interface Crop {
|
||||
originX: number;
|
||||
originY: number;
|
||||
width: number;
|
||||
height: number;
|
||||
crop: {
|
||||
originX: number;
|
||||
originY: number;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
}
|
||||
|
||||
interface ImageResult {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"moment": "^2.19.4"
|
||||
}
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// Type definitions for is-blank 2.1
|
||||
// Project: https://github.com/johnotander/is-blank#readme
|
||||
// Definitions by: Christian Gambardella <https://github.com/heygambo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function isBlank(input: any): boolean;
|
||||
export = isBlank;
|
||||
@@ -0,0 +1,17 @@
|
||||
import isBlank = require('is-blank');
|
||||
|
||||
isBlank([]); // => true
|
||||
isBlank({}); // => true
|
||||
isBlank(0); // => true
|
||||
isBlank(() => {}); // => true
|
||||
isBlank(null); // => true
|
||||
isBlank(undefined); // => true
|
||||
isBlank(''); // => true
|
||||
isBlank(' '); // => true
|
||||
isBlank('\r\t\n '); // => true
|
||||
|
||||
isBlank(['a', 'b']); // => false
|
||||
isBlank({ a: 'b' }); // => false
|
||||
isBlank('string'); // => false
|
||||
isBlank(42); // => false
|
||||
isBlank((a: number, b: number) => a + b);
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"is-blank-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+97
-89
@@ -1722,6 +1722,9 @@ declare module "mongoose" {
|
||||
* If later in the query chain a method returns Query<T>, we will need to know type T.
|
||||
* So we save this type as the second type parameter in DocumentQuery. Since people have
|
||||
* been using Query<T>, we set it as an alias of DocumentQuery.
|
||||
*
|
||||
* Furthermore, Query<T> is used for function that has an option { rawResult: true }.
|
||||
* for instance findOneAndUpdate.
|
||||
*/
|
||||
class Query<T> extends DocumentQuery<T, any> { }
|
||||
class DocumentQuery<T, DocType extends Document, QueryHelpers = {}> extends mquery {
|
||||
@@ -1864,7 +1867,7 @@ declare module "mongoose" {
|
||||
equals<T>(val: T): this;
|
||||
|
||||
/** Executes the query */
|
||||
exec(callback?: (err: any, res: T) => void): Promise<T>;
|
||||
exec(callback?: (err: NativeError, res: T) => void): Promise<T>;
|
||||
exec(operation: string | Function, callback?: (err: any, res: T) => void): Promise<T>;
|
||||
|
||||
/** Specifies an $exists condition */
|
||||
@@ -1895,10 +1898,16 @@ declare module "mongoose" {
|
||||
* Issues a mongodb findAndModify remove command.
|
||||
* Finds a matching document, removes it, passing the found document (if any) to the
|
||||
* callback. Executes immediately if callback is passed.
|
||||
*
|
||||
* If mongoose option 'useFindAndModify': set to false it uses native findOneAndUpdate() rather than deprecated findAndModify().
|
||||
* https://mongoosejs.com/docs/api.html#mongoose_Mongoose-set
|
||||
*/
|
||||
findOneAndRemove(callback?: (error: any, doc: DocType | null, result: any) => void): DocumentQuery<DocType | null, DocType> & QueryHelpers;
|
||||
findOneAndRemove(conditions: any,
|
||||
callback?: (error: any, doc: DocType | null, result: any) => void): DocumentQuery<DocType | null, DocType> & QueryHelpers;
|
||||
findOneAndRemove(conditions: any, options: { rawResult: true } & QueryFindOneAndRemoveOptions,
|
||||
callback?: (error: any, doc: mongodb.FindAndModifyWriteOpResultObject<DocType | null>, result: any) => void)
|
||||
: Query<mongodb.FindAndModifyWriteOpResultObject<DocType | null>> & QueryHelpers;
|
||||
findOneAndRemove(conditions: any, options: QueryFindOneAndRemoveOptions,
|
||||
callback?: (error: any, doc: DocType | null, result: any) => void): DocumentQuery<DocType | null, DocType> & QueryHelpers;
|
||||
|
||||
@@ -1906,6 +1915,9 @@ declare module "mongoose" {
|
||||
* Issues a mongodb findAndModify update command.
|
||||
* Finds a matching document, updates it according to the update arg, passing any options, and returns
|
||||
* the found document (if any) to the callback. The query executes immediately if callback is passed.
|
||||
*
|
||||
* If mongoose option 'useFindAndModify': set to false it uses native findOneAndUpdate() rather than deprecated findAndModify().
|
||||
* https://mongoosejs.com/docs/api.html#mongoose_Mongoose-set
|
||||
*/
|
||||
findOneAndUpdate(callback?: (err: any, doc: DocType | null) => void): DocumentQuery<DocType | null, DocType> & QueryHelpers;
|
||||
findOneAndUpdate(update: any,
|
||||
@@ -1913,8 +1925,15 @@ declare module "mongoose" {
|
||||
findOneAndUpdate(query: any, update: any,
|
||||
callback?: (err: any, doc: DocType | null, res: any) => void): DocumentQuery<DocType | null, DocType> & QueryHelpers;
|
||||
findOneAndUpdate(query: any, update: any,
|
||||
options: { upsert: true, new: true } & QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, doc: DocType, res: any) => void): DocumentQuery<DocType | null, DocType> & QueryHelpers;
|
||||
options: { rawResult: true } & { upsert: true } & { new: true } & QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, doc: mongodb.FindAndModifyWriteOpResultObject<DocType>, res: any) => void)
|
||||
: Query<mongodb.FindAndModifyWriteOpResultObject<DocType>> & QueryHelpers;
|
||||
findOneAndUpdate(query: any, update: any,
|
||||
options: { upsert: true } & { new: true } & QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, doc: DocType, res: any) => void): DocumentQuery<DocType, DocType> & QueryHelpers;
|
||||
findOneAndUpdate(query: any, update: any, options: { rawResult: true } & QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, doc: mongodb.FindAndModifyWriteOpResultObject<DocType | null>, res: any) => void)
|
||||
: Query<mongodb.FindAndModifyWriteOpResultObject<DocType | null>> & QueryHelpers;
|
||||
findOneAndUpdate(query: any, update: any, options: QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, doc: DocType | null, res: any) => void): DocumentQuery<DocType | null, DocType> & QueryHelpers;
|
||||
|
||||
@@ -2238,12 +2257,21 @@ declare module "mongoose" {
|
||||
class mquery { }
|
||||
|
||||
interface QueryFindOneAndRemoveOptions {
|
||||
/** if multiple docs are found by the conditions, sets the sort order to choose which doc to update */
|
||||
/**
|
||||
* if multiple docs are found by the conditions, sets the sort order to choose
|
||||
* which doc to update
|
||||
*/
|
||||
sort?: any;
|
||||
/** puts a time limit on the query - requires mongodb >= 2.6.0 */
|
||||
maxTimeMS?: number;
|
||||
/** if true, passes the raw result from the MongoDB driver as the third callback parameter */
|
||||
/** sets the document fields to return */
|
||||
select?: any;
|
||||
/** like select, it determines which fields to return */
|
||||
projection?: any;
|
||||
/** if true, returns the raw result from the MongoDB driver */
|
||||
rawResult?: boolean;
|
||||
/** overwrites the schema's strict mode option for this update */
|
||||
strict?: boolean|string;
|
||||
}
|
||||
|
||||
interface QueryFindOneAndUpdateOptions extends QueryFindOneAndRemoveOptions {
|
||||
@@ -2251,8 +2279,6 @@ declare module "mongoose" {
|
||||
new?: boolean;
|
||||
/** creates the object if it doesn't exist. defaults to false. */
|
||||
upsert?: boolean;
|
||||
/** Field selection. Equivalent to .select(fields).findOneAndUpdate() */
|
||||
fields?: any | string;
|
||||
/** if true, runs update validators on this command. Update validators validate the update operation against the model's schema. */
|
||||
runValidators?: boolean;
|
||||
/**
|
||||
@@ -2270,6 +2296,8 @@ declare module "mongoose" {
|
||||
* Turn on this option to aggregate all the cast errors.
|
||||
*/
|
||||
multipleCastError?: boolean;
|
||||
/** Field selection. Equivalent to .select(fields).findOneAndUpdate() */
|
||||
fields?: any | string;
|
||||
}
|
||||
|
||||
interface QueryUpdateOptions extends ModelUpdateOptions {
|
||||
@@ -2998,17 +3026,21 @@ declare module "mongoose" {
|
||||
* findByIdAndRemove(id, ...) is equivalent to findOneAndRemove({ _id: id }, ...).
|
||||
* Finds a matching document, removes it, passing the found document (if any) to the callback.
|
||||
* Executes immediately if callback is passed, else a Query object is returned.
|
||||
*
|
||||
* If mongoose option 'useFindAndModify': set to false it uses native findOneAndUpdate() rather than deprecated findAndModify().
|
||||
* https://mongoosejs.com/docs/api.html#mongoose_Mongoose-set
|
||||
*
|
||||
* Note: same signatures as findByIdAndDelete
|
||||
*
|
||||
* @param id value of _id to query by
|
||||
*/
|
||||
findByIdAndRemove(): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findByIdAndRemove(id: any | number | string,
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findByIdAndRemove(id: any | number | string, options: {
|
||||
/** if multiple docs are found by the conditions, sets the sort order to choose which doc to update */
|
||||
sort?: any;
|
||||
/** sets the document fields to return */
|
||||
select?: any;
|
||||
}, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findByIdAndRemove(id: any | number | string, options: QueryFindOneAndRemoveOptions,
|
||||
callback?: (err: any, res: mongodb.FindAndModifyWriteOpResultObject<T | null>) => void)
|
||||
: Query<mongodb.FindAndModifyWriteOpResultObject<T | null>> & QueryHelpers;
|
||||
findByIdAndRemove(id: any | number | string, options: QueryFindOneAndRemoveOptions, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
|
||||
|
||||
/**
|
||||
@@ -3016,31 +3048,44 @@ declare module "mongoose" {
|
||||
* findByIdAndDelete(id, ...) is equivalent to findByIdAndDelete({ _id: id }, ...).
|
||||
* Finds a matching document, removes it, passing the found document (if any) to the callback.
|
||||
* Executes immediately if callback is passed, else a Query object is returned.
|
||||
*
|
||||
* Note: same signatures as findByIdAndRemove
|
||||
*
|
||||
* @param id value of _id to query by
|
||||
*/
|
||||
findByIdAndDelete(): DocumentQuery<T | null, T>;
|
||||
findByIdAndDelete(): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findByIdAndDelete(id: any | number | string,
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findByIdAndDelete(id: any | number | string, options: {
|
||||
/** if multiple docs are found by the conditions, sets the sort order to choose which doc to update */
|
||||
sort?: any;
|
||||
/** sets the document fields to return */
|
||||
select?: any;
|
||||
}, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findByIdAndDelete(id: any | number | string, options: QueryFindOneAndRemoveOptions,
|
||||
callback?: (err: any, res: mongodb.FindAndModifyWriteOpResultObject<T | null>) => void)
|
||||
: Query<mongodb.FindAndModifyWriteOpResultObject<T | null>> & QueryHelpers;
|
||||
findByIdAndDelete(id: any | number | string, options: QueryFindOneAndRemoveOptions, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
|
||||
/**
|
||||
* Issues a mongodb findAndModify update command by a document's _id field. findByIdAndUpdate(id, ...)
|
||||
* is equivalent to findOneAndUpdate({ _id: id }, ...).
|
||||
*
|
||||
* If mongoose option 'useFindAndModify': set to false it uses native findOneAndUpdate() rather than deprecated findAndModify().
|
||||
* https://mongoosejs.com/docs/api.html#mongoose_Mongoose-set
|
||||
*
|
||||
* @param id value of _id to query by
|
||||
*/
|
||||
findByIdAndUpdate(): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findByIdAndUpdate(id: any | number | string, update: any,
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findByIdAndUpdate(id: any | number | string, update: any,
|
||||
options: { upsert: true, new: true } & ModelFindByIdAndUpdateOptions,
|
||||
options: { rawResult: true } & { upsert: true } & { new: true } & QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T> & QueryHelpers;
|
||||
findByIdAndUpdate(id: any | number | string, update: any,
|
||||
options: ModelFindByIdAndUpdateOptions,
|
||||
options: { upsert: true, new: true } & QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, res: mongodb.FindAndModifyWriteOpResultObject<T>) => void)
|
||||
: Query<mongodb.FindAndModifyWriteOpResultObject<T>> & QueryHelpers;
|
||||
findByIdAndUpdate(id: any | number | string, update: any,
|
||||
options: { rawResult : true } & QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, res: mongodb.FindAndModifyWriteOpResultObject<T | null>) => void)
|
||||
: Query<mongodb.FindAndModifyWriteOpResultObject<T | null>> & QueryHelpers;
|
||||
findByIdAndUpdate(id: any | number | string, update: any,
|
||||
options: QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
|
||||
/**
|
||||
@@ -3059,62 +3104,62 @@ declare module "mongoose" {
|
||||
* Issue a mongodb findAndModify remove command.
|
||||
* Finds a matching document, removes it, passing the found document (if any) to the callback.
|
||||
* Executes immediately if callback is passed else a Query object is returned.
|
||||
*
|
||||
* If mongoose option 'useFindAndModify': set to false it uses native findOneAndUpdate() rather than deprecated findAndModify().
|
||||
* https://mongoosejs.com/docs/api.html#mongoose_Mongoose-set
|
||||
*
|
||||
* Note: same signatures as findOneAndDelete
|
||||
*
|
||||
*/
|
||||
findOneAndRemove(): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findOneAndRemove(conditions: any,
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findOneAndRemove(conditions: any, options: {
|
||||
/**
|
||||
* if multiple docs are found by the conditions, sets the sort order to choose
|
||||
* which doc to update
|
||||
*/
|
||||
sort?: any;
|
||||
/** puts a time limit on the query - requires mongodb >= 2.6.0 */
|
||||
maxTimeMS?: number;
|
||||
/** sets the document fields to return */
|
||||
select?: any;
|
||||
}, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findOneAndRemove(conditions: any, options: { rawResult: true } & QueryFindOneAndRemoveOptions,
|
||||
callback?: (err: any, doc: mongodb.FindAndModifyWriteOpResultObject<T | null>, res: any) => void)
|
||||
: Query<mongodb.FindAndModifyWriteOpResultObject<T | null>> & QueryHelpers;
|
||||
findOneAndRemove(conditions: any, options: QueryFindOneAndRemoveOptions, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
|
||||
/**
|
||||
* Issues a mongodb findOneAndDelete command.
|
||||
* Finds a matching document, removes it, passing the found document (if any) to the
|
||||
* callback. Executes immediately if callback is passed.
|
||||
*
|
||||
* Note: same signatures as findOneAndRemove
|
||||
*
|
||||
*/
|
||||
findOneAndDelete(): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findOneAndDelete(conditions: any,
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findOneAndDelete(conditions: any, options: {
|
||||
/**
|
||||
* if multiple docs are found by the conditions, sets the sort order to choose
|
||||
* which doc to update
|
||||
*/
|
||||
sort?: any;
|
||||
/** puts a time limit on the query - requires mongodb >= 2.6.0 */
|
||||
maxTimeMS?: number;
|
||||
/** sets the document fields to return */
|
||||
select?: any;
|
||||
/** like select, it determines which fields to return */
|
||||
projection?: any;
|
||||
/** if true, returns the raw result from the MongoDB driver */
|
||||
rawResult?: boolean;
|
||||
/** overwrites the schema's strict mode option for this update */
|
||||
strict?: boolean|string;
|
||||
}, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findOneAndDelete(conditions: any, options: { rawResult: true } & QueryFindOneAndRemoveOptions,
|
||||
callback?: (err: any, doc: mongodb.FindAndModifyWriteOpResultObject<T | null>, res: any) => void)
|
||||
: Query<mongodb.FindAndModifyWriteOpResultObject<T | null>> & QueryHelpers;
|
||||
findOneAndDelete(conditions: any, options: QueryFindOneAndRemoveOptions, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
|
||||
/**
|
||||
* Issues a mongodb findAndModify update command.
|
||||
* Finds a matching document, updates it according to the update arg, passing any options,
|
||||
* and returns the found document (if any) to the callback. The query executes immediately
|
||||
* if callback is passed else a Query object is returned.
|
||||
*
|
||||
+ * If mongoose option 'useFindAndModify': set to false it uses native findOneAndUpdate() rather than the deprecated findAndModify().
|
||||
+ * https://mongoosejs.com/docs/api.html#mongoose_Mongoose-set
|
||||
*/
|
||||
findOneAndUpdate(): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findOneAndUpdate(conditions: any, update: any,
|
||||
callback?: (err: any, doc: T | null, res: any) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
findOneAndUpdate(conditions: any, update: any,
|
||||
options: { upsert: true, new: true } & ModelFindOneAndUpdateOptions,
|
||||
options: { rawResult : true } & { upsert: true, new: true } & QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, doc: mongodb.FindAndModifyWriteOpResultObject<T>, res: any) => void)
|
||||
: Query<mongodb.FindAndModifyWriteOpResultObject<T>> & QueryHelpers;
|
||||
findOneAndUpdate(conditions: any, update: any,
|
||||
options: { upsert: true, new: true } & QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, doc: T, res: any) => void): DocumentQuery<T, T> & QueryHelpers;
|
||||
findOneAndUpdate(conditions: any, update: any,
|
||||
options: ModelFindOneAndUpdateOptions,
|
||||
options: { rawResult: true } & QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, doc: mongodb.FindAndModifyWriteOpResultObject<T | null>, res: any) => void)
|
||||
: Query<mongodb.FindAndModifyWriteOpResultObject<T | null>> & QueryHelpers;
|
||||
findOneAndUpdate(conditions: any, update: any,
|
||||
options: QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, doc: T | null, res: any) => void): DocumentQuery<T | null, T> & QueryHelpers;
|
||||
|
||||
/**
|
||||
@@ -3308,43 +3353,6 @@ declare module "mongoose" {
|
||||
session?: ClientSession | null;
|
||||
}
|
||||
|
||||
interface ModelFindByIdAndUpdateOptions extends ModelOptions {
|
||||
/** true to return the modified document rather than the original. defaults to false */
|
||||
new?: boolean;
|
||||
/** creates the object if it doesn't exist. defaults to false. */
|
||||
upsert?: boolean;
|
||||
/**
|
||||
* if true, runs update validators on this command. Update validators validate the
|
||||
* update operation against the model's schema.
|
||||
*/
|
||||
runValidators?: boolean;
|
||||
/**
|
||||
* if this and upsert are true, mongoose will apply the defaults specified in the model's
|
||||
* schema if a new document is created. This option only works on MongoDB >= 2.4 because
|
||||
* it relies on MongoDB's $setOnInsert operator.
|
||||
*/
|
||||
setDefaultsOnInsert?: boolean;
|
||||
/** if multiple docs are found by the conditions, sets the sort order to choose which doc to update */
|
||||
sort?: any;
|
||||
/** sets the document fields to return */
|
||||
select?: any;
|
||||
/** if true, passes the raw result from the MongoDB driver as the third callback parameter */
|
||||
rawResult?: boolean;
|
||||
/** overwrites the schema's strict mode option for this update */
|
||||
strict?: boolean;
|
||||
/** The context option lets you set the value of this in update validators to the underlying query. */
|
||||
context?: string;
|
||||
}
|
||||
|
||||
interface ModelFindOneAndUpdateOptions extends ModelFindByIdAndUpdateOptions {
|
||||
/** Field selection. Equivalent to .select(fields).findOneAndUpdate() */
|
||||
fields?: any | string;
|
||||
/** puts a time limit on the query - requires mongodb >= 2.6.0 */
|
||||
maxTimeMS?: number;
|
||||
/** if true, passes the raw result from the MongoDB driver as the third callback parameter */
|
||||
rawResult?: boolean;
|
||||
}
|
||||
|
||||
interface ModelPopulateOptions {
|
||||
/** space delimited path(s) to populate */
|
||||
path: string;
|
||||
|
||||
@@ -1021,7 +1021,7 @@ query.findOne(function (err, res) {
|
||||
query.findOneAndRemove({name: 'aa'}, {
|
||||
rawResult: true
|
||||
}, function (err, doc) {
|
||||
doc.execPopulate();
|
||||
doc.lastErrorObject
|
||||
}).findOneAndRemove();
|
||||
query.findOneAndUpdate({name: 'aa'}, {name: 'bb'}, {
|
||||
|
||||
@@ -1911,6 +1911,14 @@ LocModel.findOneAndUpdate().exec().then(function (arg) {
|
||||
arg.openingTimes;
|
||||
}
|
||||
});
|
||||
LocModel.findOneAndUpdate(
|
||||
// find a document with that filter
|
||||
{name: "aa"},
|
||||
// document to insert when nothing was found
|
||||
{ $set: {name: "bb"} },
|
||||
// options
|
||||
{upsert: true, new: true, runValidators: true,
|
||||
rawResult: true, multipleCastError: true });
|
||||
LocModel.geoSearch({}, {
|
||||
near: [1, 2],
|
||||
maxDistance: 22
|
||||
|
||||
Vendored
+63
@@ -0,0 +1,63 @@
|
||||
// Type definitions for mumath 3.3
|
||||
// Project: https://github.com/dfcreative/mumath
|
||||
// Definitions by: Adam Zerella <https://github.com/adamzerella>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.3
|
||||
|
||||
/**
|
||||
* Detects proper clamp min/max.
|
||||
*/
|
||||
export function clamp(value: number, left: number, right: number): number;
|
||||
|
||||
/**
|
||||
* Get closest value out of a set.
|
||||
*/
|
||||
export function closest(value: number, list: number[]): number;
|
||||
|
||||
/**
|
||||
* Check if one number is multiple of other
|
||||
* Same as a % b === 0, but with precision check.
|
||||
*/
|
||||
export function isMultiple(a: number, b: number, eps?: number): boolean;
|
||||
|
||||
/**
|
||||
* Return quadratic length of a vector.
|
||||
*/
|
||||
export function len(a: number, b: number): number;
|
||||
|
||||
/**
|
||||
* Return value interpolated between x and y.
|
||||
*/
|
||||
export function lerp(x: number, y: number, ratio: number): number;
|
||||
|
||||
/**
|
||||
* An enhanced mod-loop, like fmod — loops value within a frame.
|
||||
*/
|
||||
export function mod(value: number, max: number, min?: number): number;
|
||||
|
||||
/**
|
||||
* Get order of magnitude for a number.
|
||||
*/
|
||||
export function order(value: number): number;
|
||||
|
||||
/**
|
||||
* Get precision from float:
|
||||
*/
|
||||
export function precision(value: number): number;
|
||||
|
||||
/**
|
||||
* Rounds value to optional step.
|
||||
*/
|
||||
export function round(value: number, step?: number): number;
|
||||
|
||||
/**
|
||||
* Get first scale out of a list of basic scales, aligned to the power. E. g.
|
||||
* step(.37, [1, 2, 5]) → .5 step(456, [1, 2]) → 1000
|
||||
* Similar to closest, but takes all possible powers of scales.
|
||||
*/
|
||||
export function scale(value: number, list: number[]): number;
|
||||
|
||||
/**
|
||||
* Whether element is between left & right, including.
|
||||
*/
|
||||
export function within(value: number, left: number, right: number): number;
|
||||
@@ -0,0 +1,25 @@
|
||||
import * as mumath from "mumath";
|
||||
|
||||
mumath.clamp(1, 2, 3);
|
||||
|
||||
mumath.closest(5, [1, 7, 3, 6, 10]);
|
||||
|
||||
mumath.isMultiple(5, 10, 1.000074);
|
||||
mumath.isMultiple(5, 10);
|
||||
|
||||
mumath.len(15, 1.0);
|
||||
|
||||
mumath.lerp(1, 2, 3);
|
||||
|
||||
mumath.mod(1, 2, 3);
|
||||
mumath.mod(1, 2);
|
||||
|
||||
mumath.order(5);
|
||||
|
||||
mumath.precision(5.0000001);
|
||||
|
||||
mumath.round(0.3, 0.5);
|
||||
|
||||
mumath.scale(5.93, [1.0, 35, 10, 7.135]);
|
||||
|
||||
mumath.within(5, 1, 10);
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [
|
||||
|
||||
],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"mumath-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"moment": "^2.19.4"
|
||||
}
|
||||
}
|
||||
Vendored
+4
-2
@@ -9297,7 +9297,9 @@ export const PointPropType: React.Validator<PointPropType>;
|
||||
export const ViewPropTypes: React.ValidationMap<ViewProps>;
|
||||
|
||||
declare global {
|
||||
function require(name: string): any;
|
||||
type ReactNativeRequireFunction = (name: string) => any;
|
||||
|
||||
var require: ReactNativeRequireFunction;
|
||||
|
||||
/**
|
||||
* Console polyfill
|
||||
@@ -9315,7 +9317,7 @@ declare global {
|
||||
ignoredYellowBox: string[];
|
||||
}
|
||||
|
||||
const console: Console;
|
||||
var console: Console;
|
||||
|
||||
/**
|
||||
* Navigator object for accessing location API
|
||||
|
||||
Vendored
+2
-1
@@ -30,7 +30,7 @@ export type TooltipFormatter = (value: string | number | Array<string | number>,
|
||||
entry: TooltipPayload, index: number) => React.ReactNode;
|
||||
export type ItemSorter<T> = (a: T, b: T) => number;
|
||||
export type ContentRenderer<P> = (props: P) => React.ReactNode;
|
||||
export type DataKey = string | number | ((dataObject: any) => number | [number, number] | null);
|
||||
export type DataKey = string | number | ((dataObject: any) => string | number | [number, number] | null);
|
||||
|
||||
export type IconType = 'plainline' | 'line' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'plainline';
|
||||
export type LegendType = IconType | 'none';
|
||||
@@ -201,6 +201,7 @@ export interface BarProps extends EventAttributes, Partial<PresentationAttribute
|
||||
dataKey: DataKey; // As the source code states, dataKey will replace valueKey in 1.1.0 and it'll be required (it's already required in current implementation).
|
||||
className?: string;
|
||||
fill?: string;
|
||||
radius?: number | number[];
|
||||
layout?: LayoutType;
|
||||
xAxisId?: string | number;
|
||||
yAxisId?: string | number;
|
||||
|
||||
@@ -204,7 +204,7 @@ class Component extends React.Component<{}, ComponentState> {
|
||||
<Bar dataKey="pv" fill="#8884d8">
|
||||
<LabelList dataKey="name" position="insideTop" angle={45} />
|
||||
</Bar>
|
||||
<Bar dataKey="uv" fill="#82ca9d">
|
||||
<Bar dataKey="uv" fill="#82ca9d" radius={[10, 10, 0, 0]}>
|
||||
<LabelList dataKey="uv" position="top" />
|
||||
</Bar>
|
||||
</BarChart>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"moment": "^2.19.4"
|
||||
}
|
||||
}
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import shipit = require("shipit");
|
||||
import shipit = require("shipit-cli");
|
||||
|
||||
export type GruntOrShipit = typeof shipit | {};
|
||||
export type EmptyCallback = () => void;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import shipit = require("shipit");
|
||||
import shipit = require("shipit-cli");
|
||||
import utils = require("shipit-utils");
|
||||
|
||||
const originalShipit = utils.getShipit(shipit);
|
||||
|
||||
+13
-1
@@ -1,7 +1,8 @@
|
||||
// Type definitions for @storybook/addon-info 3.4
|
||||
// Type definitions for @storybook/addon-info 4.1
|
||||
// Project: https://github.com/storybooks/storybook, https://github.com/storybooks/storybook/tree/master/addons/info
|
||||
// Definitions by: Mark Kornblum <https://github.com/mkornblum>
|
||||
// Mattias Wikstrom <https://github.com/fyrkant>
|
||||
// Kevin Lee <https://github.com/RunningCoderLee>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -22,11 +23,22 @@ export interface Options {
|
||||
propTables?: React.ComponentType[] | false;
|
||||
propTablesExclude?: React.ComponentType[];
|
||||
styles?: object;
|
||||
components?: { [key: string]: React.ComponentType };
|
||||
marksyConf?: object;
|
||||
maxPropsIntoLine?: number;
|
||||
maxPropObjectKeys?: number;
|
||||
maxPropArrayLength?: number;
|
||||
maxPropStringLength?: number;
|
||||
TableComponent?: React.ComponentType<{
|
||||
propDefinitions: Array<{
|
||||
property: string;
|
||||
propType: object | string; // TODO: info about what this object is...
|
||||
required: boolean;
|
||||
description: string;
|
||||
defaultValue: any;
|
||||
}>
|
||||
}>;
|
||||
excludedPropTypes?: string[];
|
||||
}
|
||||
|
||||
// TODO: it would be better to use type inference for the parameters
|
||||
|
||||
@@ -6,6 +6,38 @@ import { setDefaults, withInfo } from '@storybook/addon-info';
|
||||
|
||||
const { Component } = React;
|
||||
|
||||
const TableComponent = ({ propDefinitions }: { propDefinitions: Array<{
|
||||
property: string;
|
||||
propType: { [key: string]: any} | string;
|
||||
required: boolean;
|
||||
description: string;
|
||||
defaultValue: any;
|
||||
}> }) => (
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>property</th>
|
||||
<th>propType</th>
|
||||
<th>required</th>
|
||||
<th>default</th>
|
||||
<th>description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{propDefinitions.map(row => (
|
||||
<tr key={row.property}>
|
||||
<td>{row.property}</td>
|
||||
<td>{row.required ? 'yes' : '-'}</td>
|
||||
<td>
|
||||
{row.defaultValue === undefined ? '-' : row.defaultValue}
|
||||
</td>
|
||||
<td>{row.description}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
);
|
||||
|
||||
addDecorator(withInfo);
|
||||
|
||||
setDefaults({
|
||||
@@ -31,11 +63,14 @@ storiesOf('Component', module)
|
||||
header: true,
|
||||
source: true,
|
||||
styles: {},
|
||||
components: {},
|
||||
marksyConf: {},
|
||||
maxPropObjectKeys: 1,
|
||||
maxPropArrayLength: 2,
|
||||
maxPropsIntoLine: 3,
|
||||
maxPropStringLength: 4,
|
||||
TableComponent,
|
||||
excludedPropTypes: [],
|
||||
})(() =>
|
||||
<Component>Click the "?" mark at top-right to view the info.</Component>
|
||||
)
|
||||
|
||||
Vendored
+268
@@ -0,0 +1,268 @@
|
||||
// Type definitions for tokenizr 1.5
|
||||
// Project: https://github.com/rse/tokenizr
|
||||
// Definitions by: Nicholas Sorokin <https://github.com/aNickzz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare class Tokenizr {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Configure a tokenization after-rule callback
|
||||
*/
|
||||
after(action: Action): this;
|
||||
|
||||
/**
|
||||
* Execute multiple alternative callbacks
|
||||
*/
|
||||
alternatives(...alternatives: Array<(this: this) => any>): any;
|
||||
|
||||
/**
|
||||
* Configure a tokenization before-rule callback
|
||||
*/
|
||||
before(action: Action): this;
|
||||
|
||||
/**
|
||||
* Open tokenization transaction
|
||||
*/
|
||||
begin(): this;
|
||||
|
||||
/**
|
||||
* Close (successfully) tokenization transaction
|
||||
*/
|
||||
commit(): this;
|
||||
|
||||
/**
|
||||
* Consume the current token (by expecting it to be a particular symbol)
|
||||
*/
|
||||
consume(type: string, value: any): Token;
|
||||
|
||||
/**
|
||||
* Configure debug operation
|
||||
*/
|
||||
debug(enableDebug: boolean): this;
|
||||
|
||||
/**
|
||||
* Determine depth of still open tokenization transaction
|
||||
*/
|
||||
depth(): number;
|
||||
|
||||
/**
|
||||
* Create an error message for the current position
|
||||
*/
|
||||
error(message?: string): ParsingError;
|
||||
|
||||
/**
|
||||
* Configure a tokenization finish callback
|
||||
*/
|
||||
finish(action: (this: ActionContext, ctx: ActionContext) => void): this;
|
||||
|
||||
/**
|
||||
* Provide (new) input string to tokenize
|
||||
*/
|
||||
input(input: string): this;
|
||||
|
||||
/**
|
||||
* Peek at the next token or token at particular offset
|
||||
*/
|
||||
peek(offset?: number): Token;
|
||||
|
||||
/**
|
||||
* Pop state
|
||||
*/
|
||||
pop(): string;
|
||||
|
||||
/**
|
||||
* Push state
|
||||
*/
|
||||
push(state: string): this;
|
||||
|
||||
/**
|
||||
* Reset the internal state
|
||||
*/
|
||||
reset(): this;
|
||||
|
||||
/**
|
||||
* Close (unsuccessfully) tokenization transaction
|
||||
*/
|
||||
rollback(): this;
|
||||
|
||||
/**
|
||||
* Configure a tokenization rule
|
||||
*/
|
||||
rule(pattern: RegExp, action: RuleAction, name?: string): this;
|
||||
rule(
|
||||
state: string,
|
||||
pattern: RegExp,
|
||||
action: RuleAction,
|
||||
name: string
|
||||
): this;
|
||||
|
||||
/**
|
||||
* Skip one or more tokens
|
||||
*/
|
||||
skip(len?: number): this;
|
||||
|
||||
/**
|
||||
* Get/set state
|
||||
*/
|
||||
state(): string;
|
||||
/**
|
||||
* Replaces the current state
|
||||
*/
|
||||
state(state: string): this;
|
||||
|
||||
/**
|
||||
* Set a tag
|
||||
*/
|
||||
tag(tag: string): this;
|
||||
|
||||
/**
|
||||
* Check whether tag is set
|
||||
*/
|
||||
tagged(tag: string): boolean;
|
||||
|
||||
/**
|
||||
* Determine and return next token
|
||||
*/
|
||||
token(): Token | null;
|
||||
|
||||
/**
|
||||
* Determine and return all tokens
|
||||
*/
|
||||
tokens(): Token[];
|
||||
|
||||
/**
|
||||
* Unset a tag
|
||||
*/
|
||||
untag(tag: string): this;
|
||||
|
||||
static readonly ParsingError: typeof ParsingError;
|
||||
static readonly ActionContext: typeof ActionContext;
|
||||
static readonly Token: typeof Token;
|
||||
}
|
||||
|
||||
type Action = (
|
||||
this: ActionContext,
|
||||
ctx: ActionContext,
|
||||
found: RegExpExecArray,
|
||||
rule: {
|
||||
state: string;
|
||||
pattern: RegExp;
|
||||
action: RuleAction;
|
||||
name: string;
|
||||
}
|
||||
) => void;
|
||||
|
||||
type RuleAction = (
|
||||
this: ActionContext,
|
||||
ctx: ActionContext,
|
||||
found: RegExpExecArray
|
||||
) => void;
|
||||
|
||||
declare class ActionContext {
|
||||
constructor(e: any);
|
||||
|
||||
/**
|
||||
* Accept current matching as a new token
|
||||
*/
|
||||
accept(type: string, value?: any): this;
|
||||
|
||||
/**
|
||||
* Store and retrieve user data attached to context
|
||||
*/
|
||||
data(key: string, value?: any): any;
|
||||
|
||||
/**
|
||||
* Mark current matching to be ignored
|
||||
*/
|
||||
ignore(): this;
|
||||
|
||||
/**
|
||||
* Retrieve information of current matching
|
||||
*/
|
||||
info(): { line: number; column: number; pos: number; len: number };
|
||||
|
||||
/**
|
||||
* Pop state
|
||||
*/
|
||||
pop(): string;
|
||||
|
||||
/**
|
||||
* Push state
|
||||
*/
|
||||
push(state: string): this;
|
||||
|
||||
/**
|
||||
* Rark current matching to be rejected
|
||||
*/
|
||||
reject(): this;
|
||||
|
||||
/**
|
||||
* Mark current matching to be repeated from scratch
|
||||
*/
|
||||
repeat(): this;
|
||||
|
||||
/**
|
||||
* Get/set state
|
||||
*/
|
||||
state(): string;
|
||||
/**
|
||||
* Replaces the current state
|
||||
*/
|
||||
state(state: string): this;
|
||||
|
||||
/**
|
||||
* Immediately stop tokenization
|
||||
*/
|
||||
stop(): this;
|
||||
|
||||
/**
|
||||
* Set a tag
|
||||
*/
|
||||
tag(tag: string): this;
|
||||
|
||||
/**
|
||||
* Check whether tag is set
|
||||
*/
|
||||
tagged(tag: string): boolean;
|
||||
|
||||
/**
|
||||
* Unset a tag
|
||||
*/
|
||||
untag(tag: string): this;
|
||||
}
|
||||
|
||||
declare class ParsingError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
pos: number,
|
||||
line: number,
|
||||
column: number,
|
||||
input: string
|
||||
);
|
||||
|
||||
/**
|
||||
* Render a useful string representation
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
declare class Token {
|
||||
constructor(
|
||||
type: string,
|
||||
value: any,
|
||||
text: string,
|
||||
pos?: number,
|
||||
line?: number,
|
||||
column?: number
|
||||
);
|
||||
|
||||
isA(type: string, value?: any): boolean;
|
||||
|
||||
/**
|
||||
* Render a useful string representation
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
export = Tokenizr;
|
||||
@@ -0,0 +1,42 @@
|
||||
import Tokenizr = require('tokenizr');
|
||||
|
||||
const lexer = new Tokenizr();
|
||||
|
||||
lexer.rule(/[a-zA-Z_][a-zA-Z0-9_]*/, (ctx, match) => {
|
||||
ctx.accept('id');
|
||||
});
|
||||
|
||||
lexer.rule(/[+-]?[0-9]+/, (ctx, match) => {
|
||||
ctx.accept('number', parseInt(match[0], 10));
|
||||
});
|
||||
|
||||
lexer.rule(/"((?:\\"|[^\r\n])*)"/, (ctx, match) => {
|
||||
ctx.accept('string', match[1].replace(/\\"/g, '"'));
|
||||
});
|
||||
|
||||
lexer.rule(/\/\/[^\r\n]*\r?\n/, (ctx, match) => {
|
||||
ctx.ignore();
|
||||
});
|
||||
|
||||
lexer.rule(/[ \t\r\n]+/, (ctx, match) => {
|
||||
ctx.ignore();
|
||||
});
|
||||
|
||||
lexer.rule(/./, (ctx, match) => {
|
||||
ctx.accept('char');
|
||||
});
|
||||
|
||||
const cfg = `foo {
|
||||
baz = 1 // sample comment
|
||||
bar {
|
||||
quux = 42
|
||||
hello = "hello \"world\"!"
|
||||
}
|
||||
quux = 7
|
||||
}`;
|
||||
|
||||
lexer.input(cfg);
|
||||
lexer.debug(true);
|
||||
lexer.tokens().forEach(token => {
|
||||
// ...
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "tokenizr-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// Type definitions for word-extractor 0.3
|
||||
// Project: https://github.com/morungos/node-word-extractor
|
||||
// Definitions by: Rodrigo Saboya <https://github.com/saboya>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare class WordExtractor {
|
||||
extract(documentPath: string): Promise<WordExtractor.Document>;
|
||||
}
|
||||
|
||||
export = WordExtractor;
|
||||
|
||||
declare namespace WordExtractor {
|
||||
class Document {
|
||||
getBody(): string;
|
||||
getFootnotes(): string;
|
||||
getHeaders(): string;
|
||||
getAnnotations(): string;
|
||||
getEndNotes(): string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"word-extractor-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,13 @@
|
||||
import WordExtractor = require("word-extractor");
|
||||
|
||||
const extractor = new WordExtractor();
|
||||
|
||||
let temp: string;
|
||||
|
||||
const doc = extractor.extract('/path/to/file.doc').then(document => {
|
||||
temp = document.getBody();
|
||||
temp = document.getAnnotations();
|
||||
temp = document.getEndNotes();
|
||||
temp = document.getFootnotes();
|
||||
temp = document.getHeaders();
|
||||
});
|
||||
Reference in New Issue
Block a user