@cucumber/messages
Advanced tools
Comparing version 14.0.1 to 14.1.1
{ | ||
"require": ["ts-node/register", "source-map-support/register"], | ||
"require": ["tsconfig-paths/register", "ts-node/register", "source-map-support/register"], | ||
"extension": ["ts", "tsx"], | ||
"recursive": true, | ||
"timeout": 10000 | ||
"timeout": 10000 | ||
} |
{ | ||
"name": "@cucumber/messages", | ||
"version": "14.0.1", | ||
"version": "14.1.1", | ||
"description": "Protocol Buffer messages for Cucumber's inter-process communication", | ||
@@ -14,10 +14,7 @@ "main": "dist/src/index.js", | ||
"scripts": { | ||
"prepare": "npm run pbjs && npm run pbts && copyfiles src/messages.js src/messages.d.ts dist", | ||
"test": "mocha", | ||
"lint": "eslint --ext ts --max-warnings 0 src test", | ||
"lint-fix": "eslint --ext ts --max-warnings 0 --fix src test", | ||
"coverage": "nyc --reporter=html --reporter=text mocha", | ||
"pbjs": "pbjs --force-number --target static-module --wrap commonjs messages.proto --out src/messages.js", | ||
"pbts": "pbts src/messages.js > src/messages.d.ts", | ||
"build": "tsc && make src/messages.js && make src/messages.d.ts && copyfiles src/messages.js src/messages.d.ts dist", | ||
"prepublishOnly": "npm run build" | ||
"prepublishOnly": "tsc --build tsconfig.build.json && copyfiles src/messages.js src/messages.d.ts dist" | ||
}, | ||
@@ -30,19 +27,8 @@ "dependencies": { | ||
"devDependencies": { | ||
"@types/mocha": "^8.2.0", | ||
"@types/node": "^14.14.25", | ||
"@typescript-eslint/eslint-plugin": "^4.14.2", | ||
"@typescript-eslint/parser": "^4.14.2", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^14.14.35", | ||
"copyfiles": "^2.4.1", | ||
"core-js": "^3.8.3", | ||
"eslint": "^7.19.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-react": "^7.22.0", | ||
"mocha": "^8.2.1", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.2.1", | ||
"mocha": "^8.3.2", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.1.3" | ||
"typescript": "^4.2.3" | ||
}, | ||
@@ -49,0 +35,0 @@ "bugs": { |
export declare type NewId = () => string; | ||
export declare function uuid(): NewId; | ||
export declare function incrementing(): NewId; | ||
//# sourceMappingURL=IdGenerator.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.incrementing = exports.uuid = void 0; | ||
var uuid_1 = require("uuid"); | ||
const uuid_1 = require("uuid"); | ||
function uuid() { | ||
return function () { return uuid_1.v4(); }; | ||
return () => uuid_1.v4(); | ||
} | ||
exports.uuid = uuid; | ||
function incrementing() { | ||
var next = 0; | ||
return function () { return (next++).toString(); }; | ||
let next = 0; | ||
return () => (next++).toString(); | ||
} | ||
exports.incrementing = incrementing; | ||
//# sourceMappingURL=IdGenerator.js.map |
@@ -7,1 +7,2 @@ import * as TimeConversion from './TimeConversion'; | ||
export { messages, TimeConversion, IdGenerator, version }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -23,11 +23,11 @@ "use strict"; | ||
exports.version = exports.IdGenerator = exports.TimeConversion = exports.messages = void 0; | ||
var $protobuf = __importStar(require("protobufjs")); | ||
var TimeConversion = __importStar(require("./TimeConversion")); | ||
const $protobuf = __importStar(require("protobufjs")); | ||
const TimeConversion = __importStar(require("./TimeConversion")); | ||
exports.TimeConversion = TimeConversion; | ||
var IdGenerator = __importStar(require("./IdGenerator")); | ||
const IdGenerator = __importStar(require("./IdGenerator")); | ||
exports.IdGenerator = IdGenerator; | ||
var messages_1 = require("./messages"); | ||
const messages_1 = require("./messages"); | ||
var messages = messages_1.io.cucumber.messages; | ||
exports.messages = messages; | ||
var package_json_1 = require("../package.json"); | ||
const package_json_1 = require("../package.json"); | ||
Object.defineProperty(exports, "version", { enumerable: true, get: function () { return package_json_1.version; } }); | ||
@@ -34,0 +34,0 @@ $protobuf.util.Long = undefined; |
@@ -8,1 +8,2 @@ import { io } from './messages'; | ||
export declare function addDurations(durationA: messages.IDuration, durationB: messages.IDuration): messages.IDuration; | ||
//# sourceMappingURL=TimeConversion.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.addDurations = exports.durationToMilliseconds = exports.timestampToMillisecondsSinceEpoch = exports.millisecondsToDuration = exports.millisecondsSinceEpochToTimestamp = void 0; | ||
var messages_1 = require("./messages"); | ||
const messages_1 = require("./messages"); | ||
var messages = messages_1.io.cucumber.messages; | ||
var MILLISECONDS_PER_SECOND = 1e3; | ||
var NANOSECONDS_PER_MILLISECOND = 1e6; | ||
var NANOSECONDS_PER_SECOND = 1e9; | ||
const MILLISECONDS_PER_SECOND = 1e3; | ||
const NANOSECONDS_PER_MILLISECOND = 1e6; | ||
const NANOSECONDS_PER_SECOND = 1e9; | ||
function millisecondsSinceEpochToTimestamp(millisecondsSinceEpoch) { | ||
@@ -18,3 +18,3 @@ return new messages.Timestamp(toSecondsAndNanos(millisecondsSinceEpoch)); | ||
function timestampToMillisecondsSinceEpoch(timestamp) { | ||
var seconds = timestamp.seconds, nanos = timestamp.nanos; | ||
const { seconds, nanos } = timestamp; | ||
return toMillis(seconds, nanos); | ||
@@ -24,3 +24,3 @@ } | ||
function durationToMilliseconds(duration) { | ||
var seconds = duration.seconds, nanos = duration.nanos; | ||
const { seconds, nanos } = duration; | ||
return toMillis(seconds, nanos); | ||
@@ -30,4 +30,4 @@ } | ||
function addDurations(durationA, durationB) { | ||
var seconds = durationA.seconds + durationB.seconds; | ||
var nanos = durationA.nanos + durationB.nanos; | ||
let seconds = durationA.seconds + durationB.seconds; | ||
let nanos = durationA.nanos + durationB.nanos; | ||
if (nanos >= NANOSECONDS_PER_SECOND) { | ||
@@ -37,15 +37,15 @@ seconds += 1; | ||
} | ||
return new messages.Duration({ seconds: seconds, nanos: nanos }); | ||
return new messages.Duration({ seconds, nanos }); | ||
} | ||
exports.addDurations = addDurations; | ||
function toSecondsAndNanos(milliseconds) { | ||
var seconds = Math.floor(milliseconds / MILLISECONDS_PER_SECOND); | ||
var nanos = Math.floor((milliseconds % MILLISECONDS_PER_SECOND) * NANOSECONDS_PER_MILLISECOND); | ||
return { seconds: seconds, nanos: nanos }; | ||
const seconds = Math.floor(milliseconds / MILLISECONDS_PER_SECOND); | ||
const nanos = Math.floor((milliseconds % MILLISECONDS_PER_SECOND) * NANOSECONDS_PER_MILLISECOND); | ||
return { seconds, nanos }; | ||
} | ||
function toMillis(seconds, nanos) { | ||
var secondMillis = seconds * MILLISECONDS_PER_SECOND; | ||
var nanoMillis = nanos / NANOSECONDS_PER_MILLISECOND; | ||
const secondMillis = seconds * MILLISECONDS_PER_SECOND; | ||
const nanoMillis = nanos / NANOSECONDS_PER_MILLISECOND; | ||
return secondMillis + nanoMillis; | ||
} | ||
//# sourceMappingURL=TimeConversion.js.map |
export {}; | ||
//# sourceMappingURL=TimeConversionTest.d.ts.map |
@@ -6,41 +6,41 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var assert_1 = __importDefault(require("assert")); | ||
var src_1 = require("../src"); | ||
var TimeConversion_1 = require("../src/TimeConversion"); | ||
var durationToMilliseconds = src_1.TimeConversion.durationToMilliseconds, millisecondsSinceEpochToTimestamp = src_1.TimeConversion.millisecondsSinceEpochToTimestamp, millisecondsToDuration = src_1.TimeConversion.millisecondsToDuration, timestampToMillisecondsSinceEpoch = src_1.TimeConversion.timestampToMillisecondsSinceEpoch; | ||
describe('TimeConversion', function () { | ||
it('converts to and from milliseconds since epoch', function () { | ||
var millisecondsSinceEpoch = Date.now(); | ||
var timestamp = millisecondsSinceEpochToTimestamp(millisecondsSinceEpoch); | ||
var jsEpochMillisAgain = timestampToMillisecondsSinceEpoch(timestamp); | ||
const assert_1 = __importDefault(require("assert")); | ||
const src_1 = require("../src"); | ||
const TimeConversion_1 = require("../src/TimeConversion"); | ||
const { durationToMilliseconds, millisecondsSinceEpochToTimestamp, millisecondsToDuration, timestampToMillisecondsSinceEpoch, } = src_1.TimeConversion; | ||
describe('TimeConversion', () => { | ||
it('converts to and from milliseconds since epoch', () => { | ||
const millisecondsSinceEpoch = Date.now(); | ||
const timestamp = millisecondsSinceEpochToTimestamp(millisecondsSinceEpoch); | ||
const jsEpochMillisAgain = timestampToMillisecondsSinceEpoch(timestamp); | ||
assert_1.default.strictEqual(jsEpochMillisAgain, millisecondsSinceEpoch); | ||
}); | ||
it('converts to and from milliseconds duration', function () { | ||
var durationInMilliseconds = 1234; | ||
var duration = millisecondsToDuration(durationInMilliseconds); | ||
var durationMillisAgain = durationToMilliseconds(duration); | ||
it('converts to and from milliseconds duration', () => { | ||
const durationInMilliseconds = 1234; | ||
const duration = millisecondsToDuration(durationInMilliseconds); | ||
const durationMillisAgain = durationToMilliseconds(duration); | ||
assert_1.default.strictEqual(durationMillisAgain, durationInMilliseconds); | ||
}); | ||
it('converts to and from milliseconds duration (with decimal places)', function () { | ||
var durationInMilliseconds = 3.000161; | ||
var duration = millisecondsToDuration(durationInMilliseconds); | ||
var durationMillisAgain = durationToMilliseconds(duration); | ||
it('converts to and from milliseconds duration (with decimal places)', () => { | ||
const durationInMilliseconds = 3.000161; | ||
const duration = millisecondsToDuration(durationInMilliseconds); | ||
const durationMillisAgain = durationToMilliseconds(duration); | ||
assert_1.default.strictEqual(durationMillisAgain, durationInMilliseconds); | ||
}); | ||
it('adds durations (nanos only)', function () { | ||
var durationA = millisecondsToDuration(100); | ||
var durationB = millisecondsToDuration(200); | ||
var sumDuration = TimeConversion_1.addDurations(durationA, durationB); | ||
it('adds durations (nanos only)', () => { | ||
const durationA = millisecondsToDuration(100); | ||
const durationB = millisecondsToDuration(200); | ||
const sumDuration = TimeConversion_1.addDurations(durationA, durationB); | ||
assert_1.default.deepStrictEqual(sumDuration, new src_1.messages.Duration({ seconds: 0, nanos: 3e8 })); | ||
}); | ||
it('adds durations (nanos only)', function () { | ||
var durationA = millisecondsToDuration(1000); | ||
var durationB = millisecondsToDuration(2000); | ||
var sumDuration = TimeConversion_1.addDurations(durationA, durationB); | ||
it('adds durations (seconds only)', () => { | ||
const durationA = millisecondsToDuration(1000); | ||
const durationB = millisecondsToDuration(2000); | ||
const sumDuration = TimeConversion_1.addDurations(durationA, durationB); | ||
assert_1.default.deepStrictEqual(sumDuration, new src_1.messages.Duration({ seconds: 3, nanos: 0 })); | ||
}); | ||
it('adds durations (seconds and nanos)', function () { | ||
var durationA = millisecondsToDuration(1500); | ||
var durationB = millisecondsToDuration(1600); | ||
var sumDuration = TimeConversion_1.addDurations(durationA, durationB); | ||
it('adds durations (seconds and nanos)', () => { | ||
const durationA = millisecondsToDuration(1500); | ||
const durationB = millisecondsToDuration(1600); | ||
const sumDuration = TimeConversion_1.addDurations(durationA, durationB); | ||
assert_1.default.deepStrictEqual(sumDuration, new src_1.messages.Duration({ seconds: 3, nanos: 1e8 })); | ||
@@ -47,0 +47,0 @@ }); |
export {}; | ||
//# sourceMappingURL=TimeDeserialisationTest.d.ts.map |
@@ -6,7 +6,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var assert_1 = __importDefault(require("assert")); | ||
var src_1 = require("../src"); | ||
describe('time deserialisation', function () { | ||
it('should realise int64 values numbers, even if deserialised from strings', function () { | ||
var timestamp = src_1.messages.Timestamp.fromObject({ | ||
const assert_1 = __importDefault(require("assert")); | ||
const src_1 = require("../src"); | ||
describe('time deserialisation', () => { | ||
it('should realise int64 values numbers, even if deserialised from strings', () => { | ||
const timestamp = src_1.messages.Timestamp.fromObject({ | ||
seconds: '123', | ||
@@ -13,0 +13,0 @@ nanos: 456, |
{ | ||
"name": "@cucumber/messages", | ||
"version": "14.0.1", | ||
"version": "14.1.1", | ||
"description": "Protocol Buffer messages for Cucumber's inter-process communication", | ||
@@ -14,10 +14,7 @@ "main": "dist/src/index.js", | ||
"scripts": { | ||
"prepare": "npm run pbjs && npm run pbts && copyfiles src/messages.js src/messages.d.ts dist", | ||
"test": "mocha", | ||
"lint": "eslint --ext ts --max-warnings 0 src test", | ||
"lint-fix": "eslint --ext ts --max-warnings 0 --fix src test", | ||
"coverage": "nyc --reporter=html --reporter=text mocha", | ||
"pbjs": "pbjs --force-number --target static-module --wrap commonjs messages.proto --out src/messages.js", | ||
"pbts": "pbts src/messages.js > src/messages.d.ts", | ||
"build": "tsc && make src/messages.js && make src/messages.d.ts && copyfiles src/messages.js src/messages.d.ts dist", | ||
"prepublishOnly": "npm run build" | ||
"prepublishOnly": "tsc --build tsconfig.build.json && copyfiles src/messages.js src/messages.d.ts dist" | ||
}, | ||
@@ -30,19 +27,8 @@ "dependencies": { | ||
"devDependencies": { | ||
"@types/mocha": "^8.2.0", | ||
"@types/node": "^14.14.25", | ||
"@typescript-eslint/eslint-plugin": "^4.14.2", | ||
"@typescript-eslint/parser": "^4.14.2", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^14.14.35", | ||
"copyfiles": "^2.4.1", | ||
"core-js": "^3.8.3", | ||
"eslint": "^7.19.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-react": "^7.22.0", | ||
"mocha": "^8.2.1", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.2.1", | ||
"mocha": "^8.3.2", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.1.3" | ||
"typescript": "^4.2.3" | ||
}, | ||
@@ -49,0 +35,0 @@ "bugs": { |
@@ -14,11 +14,7 @@ import { io } from './messages' | ||
export function millisecondsToDuration( | ||
durationInMilliseconds: number | ||
): messages.IDuration { | ||
export function millisecondsToDuration(durationInMilliseconds: number): messages.IDuration { | ||
return new messages.Duration(toSecondsAndNanos(durationInMilliseconds)) | ||
} | ||
export function timestampToMillisecondsSinceEpoch( | ||
timestamp: messages.ITimestamp | ||
): number { | ||
export function timestampToMillisecondsSinceEpoch(timestamp: messages.ITimestamp): number { | ||
const { seconds, nanos } = timestamp | ||
@@ -48,5 +44,3 @@ return toMillis(seconds, nanos) | ||
const seconds = Math.floor(milliseconds / MILLISECONDS_PER_SECOND) | ||
const nanos = Math.floor( | ||
(milliseconds % MILLISECONDS_PER_SECOND) * NANOSECONDS_PER_MILLISECOND | ||
) | ||
const nanos = Math.floor((milliseconds % MILLISECONDS_PER_SECOND) * NANOSECONDS_PER_MILLISECOND) | ||
return { seconds, nanos } | ||
@@ -53,0 +47,0 @@ } |
@@ -42,9 +42,6 @@ import assert from 'assert' | ||
assert.deepStrictEqual( | ||
sumDuration, | ||
new messages.Duration({ seconds: 0, nanos: 3e8 }) | ||
) | ||
assert.deepStrictEqual(sumDuration, new messages.Duration({ seconds: 0, nanos: 3e8 })) | ||
}) | ||
it('adds durations (nanos only)', () => { | ||
it('adds durations (seconds only)', () => { | ||
const durationA = millisecondsToDuration(1000) | ||
@@ -54,6 +51,3 @@ const durationB = millisecondsToDuration(2000) | ||
assert.deepStrictEqual( | ||
sumDuration, | ||
new messages.Duration({ seconds: 3, nanos: 0 }) | ||
) | ||
assert.deepStrictEqual(sumDuration, new messages.Duration({ seconds: 3, nanos: 0 })) | ||
}) | ||
@@ -66,7 +60,4 @@ | ||
assert.deepStrictEqual( | ||
sumDuration, | ||
new messages.Duration({ seconds: 3, nanos: 1e8 }) | ||
) | ||
assert.deepStrictEqual(sumDuration, new messages.Duration({ seconds: 3, nanos: 1e8 })) | ||
}) | ||
}) |
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"target": "es5", | ||
"lib": [ | ||
"es2019", | ||
"dom" | ||
], | ||
"sourceMap": true, | ||
"allowJs": false, | ||
"jsx": "react", | ||
"resolveJsonModule": true, | ||
"module": "commonjs", | ||
"esModuleInterop": true, | ||
"noImplicitAny": true, | ||
"moduleResolution": "node", | ||
"outDir": "dist", | ||
"downlevelIteration": true, | ||
"skipLibCheck": true | ||
}, | ||
"include": [ | ||
"src/**/*", | ||
"test/**/*", | ||
"features/**/*" | ||
] | ||
"extends": "../../tsconfig.json" | ||
} |
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 too big to display
Sorry, the diff of this file is too big to display
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1417078
6
42
19037