Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';
import Stream from 'node:stream';

const Stream = require('stream');

const Hoek = require('@hapi/hoek');
import * as Hoek from '@hapi/hoek';


const internals = {};
Expand All @@ -19,7 +17,7 @@ const internals = {};
internals.headerRx = /^bytes=[\s,]*((?:(?:\d+\-\d*)|(?:\-\d+))(?:\s*,\s*(?:(?:\d+\-\d*)|(?:\-\d+)))*)$/i;


exports.header = function (header, length) {
const header = function (header, length) {

// Parse header

Expand Down Expand Up @@ -105,7 +103,7 @@ internals.Range = class {
};


exports.Clip = class extends Stream.Transform {
const Clip = class extends Stream.Transform {

constructor(range) {

Expand Down Expand Up @@ -183,3 +181,6 @@ internals.processChunk = function (stream, chunk) {

stream.push(chunk.slice(from, to));
};


export { header, Clip };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would much prefer if the exports are declared when defined, as it closer aligns with intentions of the style guide (to immediately know if a variable / function / class is exported).

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@hapi/ammo",
"description": "HTTP Range processing utilities",
"version": "6.0.1",
"version": "7.0.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is clearly a breaking change, the version should not be updated in the PR.

"type": "module",
"repository": "git://github.com/hapijs/ammo",
"main": "lib/index.js",
"exports": "./lib/index.js",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably also export package.json with a "./package.json": "./package.json" line.

"types": "lib/index.d.ts",
"keywords": [
"http",
Expand All @@ -30,7 +31,7 @@
"typescript": "~4.6.4"
},
"scripts": {
"test": "lab -a @hapi/code -t 100 -L -Y",
"test": "lab -a @hapi/code -Y",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omitting coverage and linting is a big no-no IMO.

I know lab doesn't currently handle coverage checks for modules, so something needs to be done. Either we update the implementation, or find an acceptable alternative.

Same goes for linting, but it is probably more of a configuration issue.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep yep, agreed. I'm omitting temporarily. This is still a TBD.

"test-cov-html": "lab -a @hapi/code -r html -o coverage.html"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm run test-cov-html does not work.

},
"license": "BSD-3-Clause"
Expand Down
16 changes: 8 additions & 8 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
'use strict';
import Stream from 'node:stream';

const Stream = require('stream');

const Ammo = require('..');
const Code = require('@hapi/code');
const Lab = require('@hapi/lab');
const Wreck = require('@hapi/wreck');
import * as Ammo from '../lib/index.js';
import * as Code from '@hapi/code';
import * as Lab from '@hapi/lab';
import Wreck from '@hapi/wreck';


const internals = {};


const { describe, it } = exports.lab = Lab.script();
const lab = Lab.script();
const { describe, it } = lab;
const expect = Code.expect;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if expect is imported directly.

export { lab };


describe('header()', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Stream from 'stream';

import * as Ammo from '..';
import * as Ammo from '../lib/index.js';
import * as Code from '@hapi/code';
import * as Lab from '@hapi/lab';
import * as Wreck from '@hapi/wreck';
Expand Down
Loading