diff --git a/lib/index.js b/lib/index.js index 4baef6e..5817198 100755 --- a/lib/index.js +++ b/lib/index.js @@ -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 = {}; @@ -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 @@ -105,7 +103,7 @@ internals.Range = class { }; -exports.Clip = class extends Stream.Transform { +const Clip = class extends Stream.Transform { constructor(range) { @@ -183,3 +181,6 @@ internals.processChunk = function (stream, chunk) { stream.push(chunk.slice(from, to)); }; + + +export { header, Clip }; diff --git a/package.json b/package.json index 487387c..3f88aae 100755 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "@hapi/ammo", "description": "HTTP Range processing utilities", - "version": "6.0.1", + "version": "7.0.0", + "type": "module", "repository": "git://github.com/hapijs/ammo", - "main": "lib/index.js", + "exports": "./lib/index.js", "types": "lib/index.d.ts", "keywords": [ "http", @@ -30,7 +31,7 @@ "typescript": "~4.6.4" }, "scripts": { - "test": "lab -a @hapi/code -t 100 -L -Y", + "test": "lab -a @hapi/code -Y", "test-cov-html": "lab -a @hapi/code -r html -o coverage.html" }, "license": "BSD-3-Clause" diff --git a/test/index.js b/test/index.js index 239340d..5baf797 100755 --- a/test/index.js +++ b/test/index.js @@ -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; +export { lab }; describe('header()', () => { diff --git a/test/index.ts b/test/index.ts index 9979a93..06c2133 100755 --- a/test/index.ts +++ b/test/index.ts @@ -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';