-
Notifications
You must be signed in to change notification settings - Fork 84
Add recommended libraries #207
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import {require as requireDefault} from "d3-require"; | ||
import constant from "./constant.js"; | ||
import DOM from "./dom/index.js"; | ||
import Files from "./files/index.js"; | ||
import {NoFileAttachments} from "./fileAttachment.js"; | ||
|
@@ -13,24 +12,39 @@ import resolve from "./resolve.js"; | |
import requirer from "./require.js"; | ||
import svg from "./svg.js"; | ||
import tex from "./tex.js"; | ||
import vegalite from "./vegalite.js"; | ||
import width from "./width.js"; | ||
|
||
export default Object.assign(function Library(resolver) { | ||
const require = requirer(resolver); | ||
Object.defineProperties(this, { | ||
DOM: {value: DOM, writable: true, enumerable: true}, | ||
FileAttachment: {value: constant(NoFileAttachments), writable: true, enumerable: true}, | ||
Files: {value: Files, writable: true, enumerable: true}, | ||
Generators: {value: Generators, writable: true, enumerable: true}, | ||
html: {value: constant(html), writable: true, enumerable: true}, | ||
md: {value: md(require), writable: true, enumerable: true}, | ||
Mutable: {value: constant(Mutable), writable: true, enumerable: true}, | ||
now: {value: now, writable: true, enumerable: true}, | ||
Promises: {value: Promises, writable: true, enumerable: true}, | ||
require: {value: constant(require), writable: true, enumerable: true}, | ||
resolve: {value: constant(resolve), writable: true, enumerable: true}, | ||
svg: {value: constant(svg), writable: true, enumerable: true}, | ||
tex: {value: tex(require), writable: true, enumerable: true}, | ||
width: {value: width, writable: true, enumerable: true} | ||
}); | ||
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, | ||
_: () => require("[email protected]/lodash.min.js"), | ||
d3: () => require("[email protected]/dist/d3.min.js"), | ||
htl: () => require("[email protected]/dist/htl.min.js"), | ||
html: () => html, | ||
md: md(require), | ||
now: now, | ||
require: () => require, | ||
resolve: () => resolve, | ||
svg: () => svg, | ||
tex: tex(require), | ||
vl: vegalite(require), | ||
width: width | ||
})); | ||
}, {resolve: requireDefault.resolve}); | ||
|
||
function properties(values) { | ||
return Object.fromEntries(Object.entries(values).map(property)); | ||
} | ||
|
||
function property([key, value]) { | ||
return [key, ({value, writable: true, enumerable: true})]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default function vl(require) { | ||
return async () => { | ||
const [vega, vegalite, api] = await Promise.all([ | ||
"[email protected]/build/vega.min.js", | ||
"[email protected]/build/vega-lite.min.js", | ||
"[email protected]/build/vega-lite-api.min.js" | ||
].map(module => require(module))); | ||
return api.register(vega, vegalite); | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is sort of not-like-the-others in this set. I assume that it is very commonly used and stable in notebooks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lodash is the most popular library on npm according to this analysis:
https://gist.github.com/anvaka/8e8fa57c7ee1350e3491
It appears to be referenced in 2.5K public notebooks according to this query:
https://observablehq.com/search?query=lodash
That’s less than Vega (9K) and D3 (10K+), but still quite popular, and I vouch for its quality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question regarding evolvability and compatibility: I started out using Ramda because of its elegant “immutable auto-curried iteratee-first data-last methods”. However, including the much more popular
lodash
library conveniently and lazily by default urges me to switch tolodash
. Plus, I just learned that there also islodash/fp
, that enjoys the same feature as Ramda above. Is there a way to includelodash/fp
by default the same way as justlodash
? Or should I fall back to an explicit require?