Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bruker-data-test

Package Overview
Dependencies
Maintainers
5
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bruker-data-test - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0-pre.1664462893

8

lib-esm/index.d.ts

@@ -1,3 +0,7 @@

export declare function getZipped(): import("filelist-from").PartialFileList;
export declare function getCoffee(): import("filelist-from").PartialFileList;
import { FileCollection } from 'filelist-utils';
export declare function getList(): Promise<string[]>;
export declare function getFile(name: string): Promise<import("filelist-utils").FileCollectionItem>;
export declare function getData(name: string): Promise<ArrayBuffer>;
export declare function getZipped(): Promise<FileCollection>;
export declare function getCoffee(): Promise<FileCollection>;
//# sourceMappingURL=index.d.ts.map
import { join } from 'path';
import { fileListFromPath } from 'filelist-from';
import { fileCollectionFromPath } from 'filelist-utils';
const root = join(__dirname, '../data');
const PATH_TO_ZIPPED = join(root, 'zipped');
const PATH_TO_COFFEE = join(root, 'flat/coffee');
const cache = {};
async function loadFileList(path) {
if (cache[path]) {
return cache[path];
}
cache[path] = await fileCollectionFromPath(path, {
unzip: { zipExtensions: [] },
ungzip: { gzipExtensions: [] },
});
return cache[path];
}
export async function getList() {
const fileCollection = await loadFileList(PATH_TO_ZIPPED);
return fileCollection.files.map((d) => d.name);
}
export async function getFile(name) {
const fileCollection = await loadFileList(PATH_TO_ZIPPED);
const file = fileCollection.files.find((file) => file.name === name);
if (!file) {
throw new Error(`There is not a zip file for ${name}`);
}
return file;
}
export async function getData(name) {
const file = await getFile(name);
return file.arrayBuffer();
}
export function getZipped() {
return fileListFromPath(join(__dirname, '../data/zipped'));
return loadFileList(PATH_TO_ZIPPED);
}
export function getCoffee() {
return fileListFromPath(join(__dirname, '../data/flat/coffee'));
return loadFileList(PATH_TO_COFFEE);
}
//# sourceMappingURL=index.js.map

@@ -1,3 +0,7 @@

export declare function getZipped(): import("filelist-from").PartialFileList;
export declare function getCoffee(): import("filelist-from").PartialFileList;
import { FileCollection } from 'filelist-utils';
export declare function getList(): Promise<string[]>;
export declare function getFile(name: string): Promise<import("filelist-utils").FileCollectionItem>;
export declare function getData(name: string): Promise<ArrayBuffer>;
export declare function getZipped(): Promise<FileCollection>;
export declare function getCoffee(): Promise<FileCollection>;
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCoffee = exports.getZipped = void 0;
exports.getCoffee = exports.getZipped = exports.getData = exports.getFile = exports.getList = void 0;
const path_1 = require("path");
const filelist_from_1 = require("filelist-from");
const filelist_utils_1 = require("filelist-utils");
const root = (0, path_1.join)(__dirname, '../data');
const PATH_TO_ZIPPED = (0, path_1.join)(root, 'zipped');
const PATH_TO_COFFEE = (0, path_1.join)(root, 'flat/coffee');
const cache = {};
async function loadFileList(path) {
if (cache[path]) {
return cache[path];
}
cache[path] = await (0, filelist_utils_1.fileCollectionFromPath)(path, {
unzip: { zipExtensions: [] },
ungzip: { gzipExtensions: [] },
});
return cache[path];
}
async function getList() {
const fileCollection = await loadFileList(PATH_TO_ZIPPED);
return fileCollection.files.map((d) => d.name);
}
exports.getList = getList;
async function getFile(name) {
const fileCollection = await loadFileList(PATH_TO_ZIPPED);
const file = fileCollection.files.find((file) => file.name === name);
if (!file) {
throw new Error(`There is not a zip file for ${name}`);
}
return file;
}
exports.getFile = getFile;
async function getData(name) {
const file = await getFile(name);
return file.arrayBuffer();
}
exports.getData = getData;
function getZipped() {
return (0, filelist_from_1.fileListFromPath)((0, path_1.join)(__dirname, '../data/zipped'));
return loadFileList(PATH_TO_ZIPPED);
}
exports.getZipped = getZipped;
function getCoffee() {
return (0, filelist_from_1.fileListFromPath)((0, path_1.join)(__dirname, '../data/flat/coffee'));
return loadFileList(PATH_TO_COFFEE);
}
exports.getCoffee = getCoffee;
//# sourceMappingURL=index.js.map
{
"name": "bruker-data-test",
"version": "0.2.1",
"version": "0.3.0-pre.1664462893",
"description": "Provides bruker NMR data files for testing purposes",

@@ -40,14 +40,14 @@ "main": "./lib/index.js",

"devDependencies": {
"@types/jest": "^27.4.1",
"eslint": "^8.10.0",
"eslint-config-cheminfo-typescript": "^10.3.0",
"jest": "^27.5.1",
"prettier": "^2.5.1",
"@types/jest": "^29.1.0",
"eslint": "^8.24.0",
"eslint-config-cheminfo-typescript": "^11.1.0",
"jest": "^29.1.1",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"ts-jest": "^27.1.3",
"typescript": "^4.6.2"
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
},
"dependencies": {
"filelist-from": "^0.2.4"
"filelist-utils": "^0.11.0"
}
}

@@ -19,9 +19,20 @@ # bruker-data-test

```js
import { getZipped, getCoffee } from 'bruker-data-test';
import { getList, getFile, getZipped } from 'bruker-data-test';
const listOfFilenames = await getList(); //list of zip file names
const filename = 'aspirin-1h.zip';
const zipped = getZipped();
const aspirin = zipped.filter((entry) => entry.name.includes('aspirin'))[0];
const data = await aspirin.arrayBuffer();
const aspirin = zipped.find((entry) => entry.name === filename);
const buffer = await aspirin.arrayBuffer();
//or
const zipBuffer = await getData(filename);
```
File list of a folder with two bruker samples
```js
import { getCoffee } from 'bruker-data-test';
const fileList = await getCoffee();
```
## License

@@ -28,0 +39,0 @@

import { join } from 'path';
import { fileListFromPath } from 'filelist-from';
import { fileCollectionFromPath, FileCollection } from 'filelist-utils';
const root = join(__dirname, '../data');
const PATH_TO_ZIPPED = join(root, 'zipped');
const PATH_TO_COFFEE = join(root, 'flat/coffee');
const cache: Record<string, FileCollection> = {};
async function loadFileList(path: string) {
if (cache[path]) {
return cache[path];
}
cache[path] = await fileCollectionFromPath(path, {
unzip: { zipExtensions: [] },
ungzip: { gzipExtensions: [] },
});
return cache[path];
}
export async function getList() {
const fileCollection = await loadFileList(PATH_TO_ZIPPED);
return fileCollection.files.map((d) => d.name);
}
export async function getFile(name: string) {
const fileCollection = await loadFileList(PATH_TO_ZIPPED);
const file = fileCollection.files.find((file) => file.name === name);
if (!file) {
throw new Error(`There is not a zip file for ${name}`);
}
return file;
}
export async function getData(name: string) {
const file = await getFile(name);
return file.arrayBuffer();
}
export function getZipped() {
return fileListFromPath(join(__dirname, '../data/zipped'));
return loadFileList(PATH_TO_ZIPPED);
}
export function getCoffee() {
return fileListFromPath(join(__dirname, '../data/flat/coffee'));
return loadFileList(PATH_TO_COFFEE);
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc