import dojo = require("./kernel"); import "../sniff"; declare class Lang { /** * Lists property names that must be explicitly processed during for-in iteration * in environments that have has("bug-for-in-skips-shadowed") true. */ _extraNames: string[]; /** * Copies/adds all properties of one or more sources to dest; returns dest. */ _mixin, U extends Record>(dest: T, source: U, copyFunc?: (s: any) => any): typeof copyFunc extends Falsy ? T & U : Record & U; /** * Copies/adds all properties of one or more sources to dest; returns dest. */ mixin, const U extends Record[]>(dest: T | Falsy, ...sources: U): T & AnyOf; /** * Set a property of a context object from a dot-separated string, such as "A.B.C": context.A.B.C = value. * @param name * @param value * @param context * @returns If the value was successfully set, the value is returned. Otherwise, undefined is returned. */ setObject(name: string, value: T, context?: Record): T | undefined; /** * Get a property from a dot-separated string, such as "A.B.C" */ getObject

>(name: P, create?: boolean, context?: C): P extends Falsy ? C : any; /** * determine if an object supports a given method */ exists(name: string, obj?: Record): boolean; /** * Return true if it is a String */ isString(it: any): it is string; /** * Return true if it is an Array. */ isArray(it: any): it is any[]; /** * Return true if it is a Function */ isFunction(it: any): it is Function; /** * Returns true if it is a JavaScript object (or an Array, a Function * or null) */ isObject(it: any): it is (null | object | any[] | Function); /** * similar to isArray() but more permissive */ isArrayLike(it: any): boolean; /** * Returns true if it is a built-in function or some other kind of * oddball that *should* report as a function but doesn't */ isAlien(it: any): boolean; /** * Adds all properties and methods of props to constructor's * prototype, making them available to all instances created with * constructor. */ extend(ctor: T, ...props: DojoJS.DeclareProps[]): DojoJS._DeclareSubclass; _hitchArgs(...[scope, method, ...args]: [...DojoJS.HitchedPair, ...Args]): DojoJS.HitchResult; /** * Returns a function that will only ever execute in the given scope. * This allows for easy use of object member functions * in callbacks and other places in which the "this" keyword may * otherwise not reference the expected scope. * Any number of default positional arguments may be passed as parameters * beyond "method". * Each of these values will be used to "placehold" (similar to curry) * for the hitched function. */ /** * Returns a function that will only ever execute in the given scope ('this' is always the scope). * @param scope The 'this' context which should be used when method executes. * @param method The property name which is a function that should be executed in scope. * @returns The 'method' property on 'scope', bound to 'scope'. */ hitch(method: DojoJS.Global extends DojoJS.WithFunc ? M : never, buffer?: any, // scope will be null, but this is not used for hitching the first x params. ...args: Args): DojoJS.HitchResult; hitch, Args extends any[]>(method: M, buffer?: any, // scope will be null, but this is not used for hitching the first x params. ...args: Args): DojoJS.HitchResult; hitch(...[scope, method, ...args]: [...DojoJS.HitchedPair, ...Args]): DojoJS.HitchResult; hitch, Args extends any[]>(scope: S, method: M, ...args: Args): DojoJS.HitchResult; /** * Returns a new object which "looks" to obj for properties which it * does not have a value for. Optionally takes a bag of properties to * seed the returned object with initially. */ delegate(obj: T, props?: U): T & U; /** * Converts an array-like object (i.e. arguments, DOMCollection) to an * array. Returns a new Array with the elements of obj. */ _toArray(obj: any, offset?: number, startWith?: any[]): any[]; /** * similar to hitch() except that the scope object is left to be * whatever the execution context eventually becomes. */ partial(method: Function | string, ...args: any[]): U; /** * Clones objects (including DOM nodes) and all children. * Warning: do not clone cyclic structures. */ clone(src: T): T; /** * Trims whitespace from both sides of the string */ trim(str: string): string; /** * Performs parameterized substitutions on a string. Throws an * exception if any parameter is unmatched. */ replace(tmpl: string, map: Record | ((match: string, name: string, offset: number, tmpl: string) => string), pattern?: RegExp): string; } declare global { namespace DojoJS { interface Dojo extends Lang { } type HitchMethod = BoundFunc | (Scope extends DojoJS.WithFunc ? X : never) | KeysWithType>; type Hitched = U extends BoundFunc ? ((...args: Skip>) => R) : U extends keyof FalsyAsGlobal ? (FalsyAsGlobal[U] extends BoundFunc ? ((...args: Skip>) => R) : never) : never; type FalsyAsGlobal = T extends Falsy ? DojoJS.Global : T; /** * A function that is bound to a given scope. * @template Scope The scope to bind to. This is the 'this' context that the function will execute in. If null, the global scope is used. * @template Args The required first arguments for the function. The function can have any number of additional arguments (optional or not). * @template R The return type of the function. */ type BoundFunc = (this: FalsyAsGlobal, ...args: [...Args, ...any[]]) => R; type WithFunc = { [k in M]: BoundFunc | null; }; type HitchedPair = [ /** When the second parameter is a string, the first param must be a object with the matching func, OR... */ scope: DojoJS.WithFunc | /** the first param must be null and the matching func exists on the global this. */ (typeof import("../global") extends DojoJS.WithFunc ? null : never), method: M ] | [ scope: S, method: KeysWithType> ]; type GlobalHitchedFunc = M extends BoundFunc ? M : M extends string ? (typeof import("../global") extends WithFunc ? M : never) : never; type HitchResult = Method extends BoundFunc ? ((...args: Skip, Length>) => R) : Method extends string ? (FalsyAsGlobal extends { [k in Method]: (infer F extends BoundFunc) | null; } ? ((...args: Skip, Length>) => ReturnType) : never) : never; } } export = dojo; //# sourceMappingURL=lang.d.ts.map