Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions types/adone/adone.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="node" />
/// <reference types="lodash" />
/// <reference types="benchmark" />
/// <reference types="async" />

declare namespace adone {
const _null: symbol;
Expand Down Expand Up @@ -110,4 +111,6 @@ declare namespace adone {
export const lodash: _.LoDashStatic;

export const benchmark: typeof tbenchmark;

export const async: typeof tasync;
}
3 changes: 3 additions & 0 deletions types/adone/async.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "async";

export as namespace tasync;
14 changes: 14 additions & 0 deletions types/adone/glosses/collections/byte_array.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ declare namespace adone.collection {
*/
readUInt16BE(offset?: number): number;

/**
* Reads a 24bit unsigned be integer
*
* @param offset Offset to read from
*/
readUInt24BE(offset?: number): number;

/**
* Reads a 32bit signed le integer
*
Expand Down Expand Up @@ -260,6 +267,13 @@ declare namespace adone.collection {
*/
writeUInt16BE(value: number, offset?: number): this;

/**
* Writes a 24bit unsigned be integer
*
* @param offset Offset to write at
*/
writeUInt24BE(value: number, offset?: number): this;

/**
* Writes a 32bit signed le integer
*
Expand Down
11 changes: 8 additions & 3 deletions types/adone/glosses/collections/fast_lru.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ declare namespace adone.collection {
*/
class FastLRU<K = any, V = any> {
/**
* @param size Cache size, unlimited by default
* @param size
*/
constructor(size?: number, options?: {
constructor(options?: {
/**
* Cache size, unlimited by default
*/
maxSize?: number;

/**
* Function that is called when a value is deleted
*/
dispose?(key: K, value: V): void
dispose?(key: K, value: V): void;
});

/**
Expand Down
2 changes: 1 addition & 1 deletion types/adone/glosses/collections/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/// <reference path="./refcounted_cache.d.ts" />
/// <reference path="./set.d.ts" />
/// <reference path="./stack.d.ts" />
/// <reference path="./timedout_map.d.ts" />
/// <reference path="./time_map.d.ts" />

declare namespace adone {
/**
Expand Down
9 changes: 2 additions & 7 deletions types/adone/glosses/collections/lru.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ declare namespace adone.collection {
* The maximum size of the cache, checked by applying the length function to all values in the cache.
* Default is Infinity
*/
max?: number;
maxSize?: number;

/**
* Maximum age in ms. Items are not pro-actively pruned out as they age,
Expand Down Expand Up @@ -85,11 +85,6 @@ declare namespace adone.collection {
* Represent an LRU cache
*/
class LRU<K = any, V = any> {
/**
* Creates an LRU cache of the given size
*/
constructor(max: number);

/**
* Creates an LRU cache with the given options
*/
Expand All @@ -98,7 +93,7 @@ declare namespace adone.collection {
/**
* The length of the cache, setter resizes the cache
*/
max: number;
maxSize: number;

/**
* stale setting
Expand Down
2 changes: 1 addition & 1 deletion types/adone/glosses/collections/ns_cache.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
declare namespace adone.collection {
class NSCache<T = any> {
constructor(size: number, namespaces: string[]);
constructor(maxSize: number, namespaces: string[]);

resize(newSize: number): void;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ declare namespace adone.collection {
/**
* Represents a Map that keeps keys only for a specified interval of time
*/
class TimedoutMap<K = any, V = any> extends Map<K, V> {
class TimeMap<K = any, V = any> extends Map<K, V> {
/**
* @param timeout maximum age of the keys, 1000 by default
* @param callback callback that is called with each key when the timeout is passed
Expand Down
29 changes: 12 additions & 17 deletions types/adone/glosses/is.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,17 @@ declare namespace adone {
/**
* Checks whether the given string is an IPv4 address
*/
export function ip4(str: string): boolean;
export function ip4(str: string, options?: adone.regex.I.IP.Options): boolean;

/**
* Checks whether the given string is an IPv6 address
*/
export function ip6(str: string): boolean;
export function ip6(str: string, options?: adone.regex.I.IP.Options): boolean;

/**
* Checks whether the given string is IPv4 or IPv6 address
*/
export function ip(str: string, options?: adone.regex.I.IP.Options): boolean;

/**
* Checks whether the given object is an array buffer
Expand Down Expand Up @@ -628,21 +633,6 @@ declare namespace adone {
requireTld?: boolean
}): obj is string;

/**
* Checks whether the given object is a valid IPv4 address
*/
export function ip(obj: any, version: 4): boolean;

/**
* Checks whether the given object is a valid IPv6 address
*/
export function ip(obj: any, version: 6): boolean;

/**
* Checks whether the given object in a valid IPv4 or IPv6 address
*/
export function ip(obj: any): boolean;

/**
* Checks whether the given object is a valid UUIDv1 identifier
*/
Expand Down Expand Up @@ -680,5 +670,10 @@ declare namespace adone {
export const openbsd: boolean;

export const aix: boolean;

/**
* Checks whether the given object is adone.multi.address.Multiaddr
*/
export function multiAddress(obj: any): boolean; // TODO: obj is adone.multi.address.Multiaddr
}
}
Loading