Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
fix: proper export
Browse files Browse the repository at this point in the history
  • Loading branch information
vaaski committed Feb 11, 2021
1 parent d7f64d3 commit 5e1e058
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"printWidth": 90,
"tabWidth": 2,
"useTabs": false,
"singleQuote": false
"singleQuote": false,
"endOfLine": "crlf"
}
2 changes: 2 additions & 0 deletions demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ const formatSize = (bytes: number, decimals = 2) => {
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i]
}

/* eslint-disable @typescript-eslint/no-unused-vars */
const client_id = process.env.SOUNDCLOUD_CLIENT_ID_V1 || "client_id"
const examplePlaylist = "https://soundcloud.com/vaaski/sets/rrrrrrrrr"
const exampleUser = "https://soundcloud.com/vaaski"
const exampleTrack = "https://soundcloud.com/vaaski/slow-night"
/* eslint-enable @typescript-eslint/no-unused-vars */

!(async () => {
const startTime = Date.now()
Expand Down
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export * from "./resolve"
import resolve from "./resolve"

export default { resolve }
export { resolve }
4 changes: 3 additions & 1 deletion src/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const htmlDataReg = /(\[{"id")(.*?)(?=\);)/i
* In browsers you have to use `resolve.browser` instead.
* @param url
*/
export const resolve = async (url: string): Promise<ScrapeResolve> => {
const resolve = async (url: string): Promise<ScrapeResolve> => {
const html = await ky(urlify(url)).text()
const [match] = html.match(htmlDataReg) || []
const parsed = JSON.parse(match)
Expand All @@ -34,3 +34,5 @@ resolve.browser = async (url: string, client_id: string): Promise<APIv1Resolve>

return data as APIv1Resolve
}

export default resolve

0 comments on commit 5e1e058

Please sign in to comment.