UNPKG

3.96 kBTypeScriptView Raw
1import { ITypedHash } from "./collections.js";
2/**
3 * Gets a callback function which will maintain context across async calls.
4 * Allows for the calling pattern getCtxCallback(thisobj, method, methodarg1, methodarg2, ...)
5 *
6 * @param context The object that will be the 'this' value in the callback
7 * @param method The method to which we will apply the context and parameters
8 * @param params Optional, additional arguments to supply to the wrapped method when it is invoked
9 */
10export declare function getCtxCallback(context: any, method: Function, ...params: any[]): Function;
11export declare type DateAddInterval = "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second";
12/**
13 * Adds a value to a date
14 *
15 * @param date The date to which we will add units, done in local time
16 * @param interval The name of the interval to add, one of: ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second']
17 * @param units The amount to add to date of the given interval
18 *
19 * http://stackoverflow.com/questions/1197928/how-to-add-30-minutes-to-a-javascript-date-object
20 */
21export declare function dateAdd(date: Date, interval: DateAddInterval, units: number): Date | undefined;
22/**
23 * Combines an arbitrary set of paths ensuring and normalizes the slashes
24 *
25 * @param paths 0 to n path parts to combine
26 */
27export declare function combine(...paths: string[]): string;
28/**
29 * Gets a random string of chars length
30 *
31 * https://stackoverflow.com/questions/1349404/generate-random-string-characters-in-javascript
32 *
33 * @param chars The length of the random string to generate
34 */
35export declare function getRandomString(chars: number): string;
36/**
37 * Gets a random GUID value
38 *
39 * http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
40 */
41export declare function getGUID(): string;
42/**
43 * Determines if a given value is a function
44 *
45 * @param cf The thing to test for functionness
46 */
47export declare function isFunc(f: any): boolean;
48/**
49 * Determines if an object is both defined and not null
50 * @param obj Object to test
51 */
52export declare function objectDefinedNotNull(obj: any): boolean;
53/**
54 * @returns whether the provided parameter is a JavaScript Array or not.
55*/
56export declare function isArray(array: any): boolean;
57/**
58 * Provides functionality to extend the given object by doing a shallow copy
59 *
60 * @param target The object to which properties will be copied
61 * @param source The source object from which properties will be copied
62 * @param noOverwrite If true existing properties on the target are not overwritten from the source
63 * @param filter If provided allows additional filtering on what properties are copied (propName: string) => boolean
64 *
65 */
66export declare function assign<T extends ITypedHash<any> = any, S extends ITypedHash<any> = any>(target: T, source: S, noOverwrite?: boolean, filter?: (propName: string) => boolean): T & S;
67/**
68 * Determines if a given url is absolute
69 *
70 * @param url The url to check to see if it is absolute
71 */
72export declare function isUrlAbsolute(url: string): boolean;
73/**
74 * Determines if a string is null or empty or undefined
75 *
76 * @param s The string to test
77 */
78export declare function stringIsNullOrEmpty(s: string): boolean;
79/**
80 * Ensures guid values are represented consistently as "ea123463-137d-4ae3-89b8-cf3fc578ca05"
81 *
82 * @param guid The candidate guid
83 */
84export declare function sanitizeGuid(guid: string): string;
85/**
86 * Shorthand for JSON.stringify
87 *
88 * @param o Any type of object
89 */
90export declare function jsS(o: any): string;
91/**
92 * Shorthand for Object.hasOwnProperty
93 *
94 * @param o Object to check for
95 * @param p Name of the property
96 */
97export declare function hOP(o: any, p: string): boolean;
98/**
99 * Generates a ~unique hash code
100 *
101 * From: https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript
102 */
103export declare function getHashCode(s: string): number;
104//# sourceMappingURL=util.d.ts.map
\No newline at end of file