UNPKG

980 BJavaScriptView Raw
1import { SPQueryable } from "./spqueryable.js";
2export class SPFI {
3 /**
4 * Creates a new instance of the SPFI class
5 *
6 * @param root Establishes a root url/configuration
7 */
8 constructor(root = "") {
9 this._root = SPQueryable(root);
10 }
11 /**
12 * Applies one or more behaviors which will be inherited by all instances chained from this root
13 *
14 */
15 using(...behaviors) {
16 this._root.using(...behaviors);
17 return this;
18 }
19 /**
20 * Used by extending classes to create new objects directly from the root
21 *
22 * @param factory The factory for the type of object to create
23 * @returns A configured instance of that object
24 */
25 create(factory, path) {
26 return factory(this._root, path);
27 }
28}
29export function spfi(root = "") {
30 if (typeof root === "object" && !Reflect.has(root, "length")) {
31 root = root._root;
32 }
33 return new SPFI(root);
34}
35//# sourceMappingURL=fi.js.map
\No newline at end of file