@flipfeatureflag/core 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ var HttpClient = class {
57
57
  constructor(options) {
58
58
  this.baseUrl = options.baseUrl.replace(/\/$/, "");
59
59
  this.sdkKey = options.sdkKey;
60
- this.fetchFn = options.fetchFn;
60
+ this.fetchFn = (options.fetchFn ?? globalThis.fetch).bind(globalThis);
61
61
  }
62
62
  async evaluate(request) {
63
63
  return this.post("/v1/sdk/flags/evaluate", request);
package/dist/index.mjs CHANGED
@@ -31,7 +31,7 @@ var HttpClient = class {
31
31
  constructor(options) {
32
32
  this.baseUrl = options.baseUrl.replace(/\/$/, "");
33
33
  this.sdkKey = options.sdkKey;
34
- this.fetchFn = options.fetchFn;
34
+ this.fetchFn = (options.fetchFn ?? globalThis.fetch).bind(globalThis);
35
35
  }
36
36
  async evaluate(request) {
37
37
  return this.post("/v1/sdk/flags/evaluate", request);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flipfeatureflag/core",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "flipFeatureFlag core SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
package/src/http.ts CHANGED
@@ -14,7 +14,7 @@ export class HttpClient {
14
14
  constructor(options: HttpClientOptions) {
15
15
  this.baseUrl = options.baseUrl.replace(/\/$/, "");
16
16
  this.sdkKey = options.sdkKey;
17
- this.fetchFn = options.fetchFn;
17
+ this.fetchFn = (options.fetchFn ?? globalThis.fetch).bind(globalThis);
18
18
  }
19
19
 
20
20
  async evaluate(request: SdkEvaluateRequest): Promise<SdkEvaluateResponse> {
@@ -26,7 +26,7 @@ export class HttpClient {
26
26
  }
27
27
 
28
28
  private async get<T>(path: string): Promise<T> {
29
- const response = await this.fetchImpl()(`${this.baseUrl}${path}`, {
29
+ const response = await this.fetchFn(`${this.baseUrl}${path}`, {
30
30
  method: "GET",
31
31
  headers: this.headers(),
32
32
  });
@@ -34,7 +34,7 @@ export class HttpClient {
34
34
  }
35
35
 
36
36
  private async post<T>(path: string, payload: unknown): Promise<T> {
37
- const response = await this.fetchImpl()(`${this.baseUrl}${path}`, {
37
+ const response = await this.fetchFn(`${this.baseUrl}${path}`, {
38
38
  method: "POST",
39
39
  headers: {
40
40
  ...this.headers(),
@@ -48,9 +48,6 @@ export class HttpClient {
48
48
  return this.parseJson(response);
49
49
  }
50
50
 
51
- private fetchImpl(): typeof fetch {
52
- return (this.fetchFn ?? globalThis.fetch).bind(globalThis);
53
- }
54
51
 
55
52
  private headers() {
56
53
  return {