Skip to content

Commit

Permalink
docs ~ update Deno examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rivy committed Jan 17, 2021
1 parent 7f02acf commit ddaeb97
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
36 changes: 36 additions & 0 deletions eg/show-paths.remote.CDN.deno.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* eslint-env es6, deno */
// # spell-checker:ignore Deno

/* eslint-disable no-console , functional/immutable-data , security/detect-object-injection, security-node/detect-crlf , @typescript-eslint/ban-ts-comment , @typescript-eslint/no-explicit-any */

// @ts-ignore
import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@2d5924e692617a575c8a73c9fb611e93085c4339/src/mod.deno.ts';
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@latest/src/mod.deno.ts';
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@6.0/src/mod.deno.ts';

// create a local reference to refer to `Deno` (for better linting without need for multiple `// @ts-ignore` directives)
// @ts-ignore
const deno = Deno;

function objectEntries(obj: any) {
const map: any = {};
Object.keys(obj).forEach((key) => {
const value = obj[key];
const val = typeof value === 'function' ? value() : value;
map[key] = val;
});
return map;
}

console.log({ osPaths });
console.log(objectEntries(osPaths));

deno.env.set('TEMP', 'temp');
deno.env.set('TMPDIR', 'tmpdir');
deno.env.set('TMP', 'tmp');
console.log(objectEntries(osPaths));

deno.env.set('TEMP', 'NEW');
console.log(objectEntries(osPaths));

/* eslint-enable no-console , functional/immutable-data , security/detect-object-injection, security-node/detect-crlf , @typescript-eslint/ban-ts-comment , @typescript-eslint/no-explicit-any */
5 changes: 1 addition & 4 deletions eg/show-paths.remote.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
/* eslint-disable no-console , functional/immutable-data , security/detect-object-injection, security-node/detect-crlf , @typescript-eslint/ban-ts-comment , @typescript-eslint/no-explicit-any */

// @ts-ignore
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@5b6b93bdb048098b86f9b8f0952180c2bf0532b1/src/mod.deno.ts';
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@2d5924e692617a575c8a73c9fb611e93085c4339/src/mod.deno.ts';
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@latest/src/mod.deno.ts';
import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@6.0/src/mod.deno.ts';
import osPaths from 'https://deno.land/x/os_paths@v6.0.0/src/mod.deno.ts';

// create a local reference to refer to `Deno` (for better linting without need for multiple `// @ts-ignore` directives)
// @ts-ignore
Expand Down

0 comments on commit ddaeb97

Please sign in to comment.