Skip to content

Expose Generators as constant #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2021
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
16 changes: 10 additions & 6 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,32 @@ import width from "./width.js";
export default Object.assign(function Library(resolver) {
const require = requirer(resolver);
Object.defineProperties(this, properties({
DOM: () => DOM,
FileAttachment: () => NoFileAttachments,
Files: () => Files,
Generators: () => Generators,
Inputs: () => require("@observablehq/[email protected]/dist/inputs.umd.min.js"),
Mutable: () => Mutable,
Plot: () => require("@observablehq/[email protected]/dist/plot.umd.min.js"),
Promises: () => Promises,
SQLite: () => SQLite(require),
_: () => require("[email protected]/lodash.min.js"),
d3: () => require("[email protected]/dist/d3.min.js"),
dot: () => require("@observablehq/[email protected]/dist/graphviz.min.js"),
htl: () => require("[email protected]/dist/htl.min.js"),
html: () => html,
md: () => md(require),
now: now,
now,
require: () => require,
resolve: () => resolve,
svg: () => svg,
tex: () => tex(require),
vl: () => vegalite(require),
width: width
width,

// Note: these are namespace objects, and thus exposed directly rather than
// being wrapped in a function. This allows library.Generators to resolve,
// rather than needing module.value.
DOM,
Files,
Generators,
Promises
}));
}, {resolve: requireDefault.resolve});

Expand Down
7 changes: 7 additions & 0 deletions test/generators/generators-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import range from "../../src/generators/range";
import valueAt from "../../src/generators/valueAt";
import observe from "../../src/generators/observe";
import queue from "../../src/generators/queue";
import Library from "../../src/library";

test("library.Generators.observe is a function", t => {
const library = new Library();
t.equal(typeof library.Generators.observe, "function");
t.end();
});

test("filter(value, fn) filters", t => {
function* input() {
Expand Down