@open-audio-stack/core 0.0.7 → 0.0.9

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.
@@ -0,0 +1,3 @@
1
+ export declare function apiBuffer(url: string): Promise<ArrayBuffer>;
2
+ export declare function apiJson(url: string): Promise<any>;
3
+ export declare function apiText(url: string): Promise<string>;
@@ -0,0 +1,12 @@
1
+ export async function apiBuffer(url) {
2
+ console.log('⤓', url);
3
+ return fetch(url).then((res) => res.arrayBuffer());
4
+ }
5
+ export async function apiJson(url) {
6
+ console.log('⤓', url);
7
+ return fetch(url).then((res) => res.json());
8
+ }
9
+ export async function apiText(url) {
10
+ console.log('⤓', url);
11
+ return fetch(url).then((res) => res.text());
12
+ }
@@ -19,6 +19,7 @@ export declare function fileDelete(filePath: string): boolean | void;
19
19
  export declare function fileExec(filePath: string): void;
20
20
  export declare function fileExists(filePath: string): boolean;
21
21
  export declare function fileJsonCreate(filePath: string, data: object): void;
22
+ export declare function fileHash(filePath: string, algorithm?: string): string;
22
23
  export declare function fileMove(filePath: string, newPath: string): void | boolean;
23
24
  export declare function fileOpen(filePath: string): Buffer;
24
25
  export declare function fileRead(filePath: string): Buffer;
@@ -1,6 +1,7 @@
1
1
  import AdmZip from 'adm-zip';
2
2
  import { execSync } from 'child_process';
3
3
  import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, unlinkSync, writeFileSync, } from 'fs';
4
+ import { createHash } from 'crypto';
4
5
  import { globSync } from 'glob';
5
6
  import { moveSync } from 'fs-extra/esm';
6
7
  import os from 'os';
@@ -125,6 +126,10 @@ export function fileExists(filePath) {
125
126
  export function fileJsonCreate(filePath, data) {
126
127
  return fileCreate(filePath, JSON.stringify(data, null, 2));
127
128
  }
129
+ export function fileHash(filePath, algorithm = 'sha256') {
130
+ const fileData = fileReadString(filePath);
131
+ return createHash(algorithm).update(fileData, 'utf8').digest('hex');
132
+ }
128
133
  export function fileMove(filePath, newPath) {
129
134
  if (fileExists(filePath)) {
130
135
  console.log('-', filePath);
@@ -1,5 +1,6 @@
1
1
  export * from './Config.js';
2
2
  export * from './Registry.js';
3
+ export * from './helpers/api.js';
3
4
  export * from './helpers/utils.js';
4
5
  export * from './types/Architecture.js';
5
6
  export * from './types/Config.js';
@@ -6,6 +6,7 @@
6
6
  export * from './Config.js';
7
7
  export * from './Registry.js';
8
8
  // Helpers
9
+ export * from './helpers/api.js';
9
10
  // export * from './helpers/file.js';
10
11
  export * from './helpers/utils.js';
11
12
  // Types
package/build/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './Config.js';
2
2
  export * from './Registry.js';
3
+ export * from './helpers/api.js';
3
4
  export * from './helpers/file.js';
4
5
  export * from './helpers/utils.js';
5
6
  export * from './types/Architecture.js';
package/build/index.js CHANGED
@@ -6,6 +6,7 @@
6
6
  export * from './Config.js';
7
7
  export * from './Registry.js';
8
8
  // Helpers
9
+ export * from './helpers/api.js';
9
10
  export * from './helpers/file.js';
10
11
  export * from './helpers/utils.js';
11
12
  // Types
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",