Skip to content

Commit

Permalink
sync with 2.0 code
Browse files Browse the repository at this point in the history
  • Loading branch information
schristley committed Oct 17, 2024
1 parent 1f22249 commit f846fc4
Show file tree
Hide file tree
Showing 8 changed files with 3,919 additions and 38 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "master", "release-1.5" ]
pull_request:
branches: [ "master", "release-1.5" ]

jobs:
build:

runs-on: ubuntu-latest

defaults:
run:
working-directory: lang/js

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
# cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
40 changes: 37 additions & 3 deletions lang/js/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ like webpack to provide an alternative entry point, and browser code can import

import { airr } from 'airr-js';

The read and write functions for AIRR Rearrangement TSV files support gzip compressed
data. File names that end with ``.gz`` extension will automatically be uncompressed
when reading or automatically compressed when writing.

Create Blank Template Schema Objects (browser, nodejs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -105,10 +108,11 @@ there is no streaming interface::
Reading AIRR Rearrangement TSV files (nodejs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The ``airr-js`` package contains functions to read and write AIRR Rearrangement
The ``airr-js`` package contains functions to read AIRR Rearrangement
TSV files as either a stream or the complete file. The streaming interface requires
two callback functions to be provided; one for the header and another for each
row as it is read::
row as it is read. The callback functions can be synchronous or they can
return a Promise::

var airr = require('airr-js');
await airr.load_schema();
Expand All @@ -125,4 +129,34 @@ row as it is read::
Writing AIRR Rearrangement TSV files (nodejs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To be implemented. These write functions will been implemented in a patch release.
The ``airr-js`` package contains functions to write AIRR Rearrangement
TSV files as either a stream or the complete file. The streaming interface requires
a callback function which provides the data for each row or returns ``null`` to indicate
no more data. The callback function can be synchronous or it can return a Promise::

var airr = require('airr-js');
await airr.load_schema();

// read some data
var data = await airr.load_rearrangement('input.airr.tsv');

// write file completely
var data = await airr.load_rearrangement(data, 'output.airr.tsv');

// for streaming, need a callback function to provide the row data
var idx = 0;
var row_callback = function(fields) {
if (idx >= data.length) return null;
else return data[idx++];
};
// write the file
await airr.create_rearrangement('output.airr.tsv', row_callback)

// callback function which returns a promise
var row_callback = function(fields) {
return new Promise(function(resolve, reject) {
// acquire some data asynchronously, e.g. from a database
row = await read_from_database();
return resolve(row);
});
};
Loading

0 comments on commit f846fc4

Please sign in to comment.