Root namespace for the modularization helpers.
- Since:
-
- 0.2.2
Methods
-
<static> configure(options)
-
Configure the gpf.require layer
Parameters:
Name Type Description options
gpf.typedef.requireOptions Options to configure
- Since:
-
- 0.2.2
Throws:
Examples
gpf.require.configure({ base: "/test/require" }); assert(gpf.require.resolve("file.js") === "/test/require/file.js");
var cache = {}; cache[gpf.require.resolve("data.json")] = {}; gpf.require.configure({ clearCache: true, cache: cache });
-
<static> define(dependencies, factory)
-
Defines a new module by executing the factory function with the specified dependent resources, see Modularization
Parameters:
Name Type Description dependencies
Object Dictionary of dependencies, the keys are preserved while passing the result dictionary to the factory function
factory
* Can be either:
- A factory function executed when all resources are resolved, the first parameter will be a dictionary with all dependencies indexed by their name (as initially specified in the dependencies parameter). The result of the factory function will be cached as the result of this resource
- Any value that will be cached as the result of this resource
- Since:
-
- 0.2.2
Returns:
Resolved with the factory function result or the object
- Type
- Promise.<*>
-
<static> resolve(name)
-
Resolves the resource name according to current require context.
Parameters:
Name Type Description name
String Relative resource name
- Since:
-
- 0.2.2
Returns:
Resolved name
- Type
- String
Example
gpf.require.configure({ base: "/test/require" }); assert(gpf.require.resolve("file.js") === "/test/require/file.js");