Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94e8c30

Browse filesBrowse files
committed
Auto-generated commit
1 parent 911c8c4 commit 94e8c30
Copy full SHA for 94e8c30

File tree

3 files changed

+44
-10
lines changed
Filter options

3 files changed

+44
-10
lines changed

‎.github/.keepalive

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2022-02-02T17:00:45.439Z
1+
2022-02-04T23:42:17.650Z

‎.github/workflows/bundle.yml

Copy file name to clipboardExpand all lines: .github/workflows/bundle.yml
+30-9Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ jobs:
6969
7070
# Rewrite all `require()`s to use jsDelivr links:
7171
find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// {
72-
s/(var|let|const)\s+([a-z0-9]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i
72+
s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i
7373
s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/
7474
s/';/@deno\/mod.js';/
7575
}"
7676
7777
# Remove `installation`, `cli`, and `c` sections:
7878
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"installation\">[^<]+<\/section>//g;"
79-
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
80-
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
79+
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
80+
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
8181
8282
- name: Publish to deno branch
8383
uses: peaceiris/actions-gh-pages@v3
@@ -107,18 +107,39 @@ jobs:
107107
run: |
108108
npm install || npm install || npm install
109109
timeout-minutes: 15
110+
- name: Extract Alias
111+
id: extract-alias
112+
run: |
113+
alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/')
114+
echo "::set-output name=alias::${alias}"
110115
- name: Create Universal Module Definition (UMD) bundle
111116
id: umd-bundle
112117
uses: stdlib-js/bundle-action@main
113118
with:
114119
target: 'umd'
120+
alias: ${{ steps.extract-alias.outputs.alias }}
115121
- name: Rewrite file contents
116122
run: |
117123
124+
# Replace links to other packages with links to the umd branch:
125+
find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/";
126+
118127
# Remove `installation`, `cli`, and `c` sections:
119128
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"installation\">[^<]+<\/section>//g;"
120-
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
121-
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
129+
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
130+
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
131+
132+
# Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag:
133+
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/bundle.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n<script type=\"text\/javascript\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/bundle.js\"><\/script>\n\`\`\`\n\nIf no recognized module system is present, access bundle contents via the global scope:\n\n\`\`\`html\n<script type=\"text\/javascript\">\n window.\2;\n<\/script>\n\`\`\`/"
134+
135+
# Rewrite examples section to be a HTML file:
136+
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\#\# Examples([\s\S]*)\`\`\`javascript([\s\S]+?)\`\`\`/\#\# Examples\1\`\`\`html\n<\!DOCTYPE html>\n<html lang=\"en\">\n<body>\n<script type=\"text\/javascript\">\2\n<\/script>\n<\/body>\n<\/html>\n\`\`\`/"
137+
138+
# Rewrite all `require()`s in the examples section as `script` tags loading the respective UMD bundle:
139+
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "1 while s/<script type=\"text\/javascript\">\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);?/<script type=\"text\/javascript\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/bundle.js\"><\/script>\n<script type=\"text\/javascript\">/g"
140+
141+
# Wrap contents of `<script type="text/javascript">` tag contents in an IIFE:
142+
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<script type=\"text\/javascript\">([\s\S]+?)<\/script>/<script type=\"text\/javascript\">\n\(function \(\) {\1}\)\(\)\n<\/script>/g"
122143
123144
- name: Publish to umd branch
124145
uses: peaceiris/actions-gh-pages@v3
@@ -175,18 +196,18 @@ jobs:
175196
176197
# Rewrite all `require()`s to use jsDelivr links:
177198
find ./esm -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// {
178-
s/(var|let|const)\s+([a-z0-9]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i
199+
s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i
179200
s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/
180201
s/';/@esm\/index.mjs';/
181202
}"
182203
183204
# Remove `installation`, `cli`, and `c` sections:
184205
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"installation\">[^<]+<\/section>//g;"
185-
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
186-
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
206+
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
207+
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
187208
188209
# Rewrite examples section to be a HTML file:
189-
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\#\# Examples([\s\S]*)\`\`\`javascript([\s\S]+?)\`\`\`/\#\# Examples\1\`\`\`html\n<\!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<script type=\"module\">\n\2\n<\/script>\n<\/head>\n<\/html>\n\`\`\`/g"
210+
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\#\# Examples([\s\S]*)\`\`\`javascript([\s\S]+?)\`\`\`/\#\# Examples\1\`\`\`html\n<\!DOCTYPE html>\n<html lang=\"en\">\n<body>\n<script type=\"module\">\n\2\n<\/script>\n<\/body>\n<\/html>\n\`\`\`/g"
190211
191212
- name: Publish to esm branch
192213
uses: peaceiris/actions-gh-pages@v3

‎README.md

Copy file name to clipboardExpand all lines: README.md
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ limitations under the License.
4242
npm install @stdlib/ndarray-array
4343
```
4444

45+
Alternatively,
46+
47+
- To load the package in a website via a `script` tag without installation and bundlers, use the [ES Module][es-module] available on the [`esm` branch][esm-url].
48+
- If you are using Deno, visit the [`deno` branch][deno-url].
49+
- For use in Observable, or in browser/node environments, use the [Universal Module Definition (UMD)][umd] build available on the [`umd` branch][umd-url].
50+
4551
</section>
4652

4753
<section class="usage">
@@ -323,6 +329,13 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
323329
324330
-->
325331

332+
[umd]: https://github.com/umdjs/umd
333+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
334+
335+
[deno-url]: https://github.com/stdlib-js/ndarray-array/tree/deno
336+
[umd-url]: https://github.com/stdlib-js/ndarray-array/tree/umd
337+
[esm-url]: https://github.com/stdlib-js/ndarray-array/tree/esm
338+
326339
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
327340
[chat-url]: https://gitter.im/stdlib-js/stdlib/
328341

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.