-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f2bfbb
commit fc28dcd
Showing
5 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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,33 @@ | ||
import nodePath from "node:path"; | ||
|
||
export default function createMithrilREPL() { | ||
const BASE_URL = "https://flems.io/"; | ||
|
||
function utoa(data) { | ||
return btoa(unescape(encodeURIComponent(data))); | ||
} | ||
|
||
function generateURLFromData(data) { | ||
return `${BASE_URL}${utoa(JSON.stringify(data))}`; | ||
} | ||
|
||
function fromContentByFilename(contentByFilename) { | ||
console.log("contentByFilename", contentByFilename); | ||
const data = Object.keys(contentByFilename).map((filename) => { | ||
const content = contentByFilename[filename]; | ||
const parsedFilename = nodePath.parse(filename); | ||
return { | ||
name: parsedFilename.name, | ||
type: parsedFilename.ext.split(".").pop(), | ||
source: content, | ||
}; | ||
}); | ||
|
||
const url = generateURLFromData(data); | ||
return url; | ||
} | ||
|
||
return { | ||
fromContentByFilename, | ||
}; | ||
} |
This file contains 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 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 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.