@groqfmt/wasm
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -6,2 +6,35 @@ 'use strict'; | ||
}); | ||
function getQueryDetails(url) { | ||
return { | ||
projectId: getProjectId(url), | ||
dataset: getDataset(url), | ||
cdn: getCdn(url), | ||
apiVersion: getApiVersion(url), | ||
perspective: getPerspective(url) | ||
}; | ||
} | ||
function getProjectId(url) { | ||
return getHostnameSegment(url, 0); | ||
} | ||
function getDataset(url) { | ||
return getPathnameSegment(url, 3); | ||
} | ||
function getCdn(url) { | ||
return getHostnameSegment(url, 1) === "apicdn"; | ||
} | ||
function getApiVersion(url) { | ||
return getPathnameSegment(url, 0); | ||
} | ||
function getPerspective(url) { | ||
var _a; | ||
return (_a = url.searchParams.get("perspective")) != null ? _a : void 0; | ||
} | ||
function getPathnameSegment(url, segmentIndex) { | ||
const separator = "/"; | ||
return url.pathname.split(separator)[segmentIndex + 1]; | ||
} | ||
function getHostnameSegment(url, segmentIndex) { | ||
const separator = "."; | ||
return url.hostname.split(separator)[segmentIndex]; | ||
} | ||
function getQueryParams(url) { | ||
@@ -35,2 +68,3 @@ return [...url.searchParams.entries()].reduce((params, _ref) => { | ||
...groqfmt(query), | ||
...getQueryDetails(url), | ||
params: getQueryParams(url) | ||
@@ -37,0 +71,0 @@ }; |
@@ -0,2 +1,13 @@ | ||
/// <reference types="bun-types" /> | ||
/** @public */ | ||
export declare interface Details { | ||
projectId: string | ||
dataset: string | ||
cdn: boolean | ||
apiVersion: string | ||
perspective?: string | ||
} | ||
/** @public */ | ||
export declare function format({ | ||
@@ -42,4 +53,4 @@ input, | ||
params?: Record<string, string> | ||
} | ||
} & Partial<Details> | ||
export {} |
{ | ||
"name": "@groqfmt/wasm", | ||
"author": "Ash", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
@@ -30,4 +30,4 @@ "repository": "github:juice49/groqfmt-wasm", | ||
"prettier": "^3.0.3", | ||
"typescript": "^5.0.0" | ||
"typescript": "^5.2.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3580063
821