@cucumber/messages
Advanced tools
Comparing version 14.1.1 to 14.1.2
{ | ||
"require": ["tsconfig-paths/register", "ts-node/register", "source-map-support/register"], | ||
"require": ["ts-node/register", "source-map-support/register"], | ||
"extension": ["ts", "tsx"], | ||
"recursive": true, | ||
"timeout": 10000 | ||
"timeout": 10000 | ||
} |
{ | ||
"name": "@cucumber/messages", | ||
"version": "14.1.1", | ||
"version": "14.1.2", | ||
"description": "Protocol Buffer messages for Cucumber's inter-process communication", | ||
@@ -14,7 +14,10 @@ "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", | ||
"prepublishOnly": "tsc --build tsconfig.build.json && copyfiles src/messages.js src/messages.d.ts dist" | ||
"build": "tsc && make src/messages.js && make src/messages.d.ts && copyfiles src/messages.js src/messages.d.ts dist", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
@@ -29,4 +32,15 @@ "dependencies": { | ||
"@types/node": "^14.14.35", | ||
"@typescript-eslint/eslint-plugin": "^4.19.0", | ||
"@typescript-eslint/parser": "^4.19.0", | ||
"copyfiles": "^2.4.1", | ||
"core-js": "^3.9.1", | ||
"eslint": "^7.22.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-react": "^7.23.0", | ||
"mocha": "^8.3.2", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.2.1", | ||
"ts-node": "^9.1.1", | ||
@@ -33,0 +47,0 @@ "typescript": "^4.2.3" |
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; | ||
const uuid_1 = require("uuid"); | ||
var uuid_1 = require("uuid"); | ||
function uuid() { | ||
return () => uuid_1.v4(); | ||
return function () { return uuid_1.v4(); }; | ||
} | ||
exports.uuid = uuid; | ||
function incrementing() { | ||
let next = 0; | ||
return () => (next++).toString(); | ||
var next = 0; | ||
return function () { return (next++).toString(); }; | ||
} | ||
exports.incrementing = incrementing; | ||
//# sourceMappingURL=IdGenerator.js.map |
@@ -7,2 +7,1 @@ 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; | ||
const $protobuf = __importStar(require("protobufjs")); | ||
const TimeConversion = __importStar(require("./TimeConversion")); | ||
var $protobuf = __importStar(require("protobufjs")); | ||
var TimeConversion = __importStar(require("./TimeConversion")); | ||
exports.TimeConversion = TimeConversion; | ||
const IdGenerator = __importStar(require("./IdGenerator")); | ||
var IdGenerator = __importStar(require("./IdGenerator")); | ||
exports.IdGenerator = IdGenerator; | ||
const messages_1 = require("./messages"); | ||
var messages_1 = require("./messages"); | ||
var messages = messages_1.io.cucumber.messages; | ||
exports.messages = messages; | ||
const package_json_1 = require("../package.json"); | ||
var 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,2 +8,1 @@ 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; | ||
const messages_1 = require("./messages"); | ||
var messages_1 = require("./messages"); | ||
var messages = messages_1.io.cucumber.messages; | ||
const MILLISECONDS_PER_SECOND = 1e3; | ||
const NANOSECONDS_PER_MILLISECOND = 1e6; | ||
const NANOSECONDS_PER_SECOND = 1e9; | ||
var MILLISECONDS_PER_SECOND = 1e3; | ||
var NANOSECONDS_PER_MILLISECOND = 1e6; | ||
var NANOSECONDS_PER_SECOND = 1e9; | ||
function millisecondsSinceEpochToTimestamp(millisecondsSinceEpoch) { | ||
@@ -18,3 +18,3 @@ return new messages.Timestamp(toSecondsAndNanos(millisecondsSinceEpoch)); | ||
function timestampToMillisecondsSinceEpoch(timestamp) { | ||
const { seconds, nanos } = timestamp; | ||
var seconds = timestamp.seconds, nanos = timestamp.nanos; | ||
return toMillis(seconds, nanos); | ||
@@ -24,3 +24,3 @@ } | ||
function durationToMilliseconds(duration) { | ||
const { seconds, nanos } = duration; | ||
var seconds = duration.seconds, nanos = duration.nanos; | ||
return toMillis(seconds, nanos); | ||
@@ -30,4 +30,4 @@ } | ||
function addDurations(durationA, durationB) { | ||
let seconds = durationA.seconds + durationB.seconds; | ||
let nanos = durationA.nanos + durationB.nanos; | ||
var seconds = durationA.seconds + durationB.seconds; | ||
var nanos = durationA.nanos + durationB.nanos; | ||
if (nanos >= NANOSECONDS_PER_SECOND) { | ||
@@ -37,15 +37,15 @@ seconds += 1; | ||
} | ||
return new messages.Duration({ seconds, nanos }); | ||
return new messages.Duration({ seconds: seconds, nanos: nanos }); | ||
} | ||
exports.addDurations = addDurations; | ||
function toSecondsAndNanos(milliseconds) { | ||
const seconds = Math.floor(milliseconds / MILLISECONDS_PER_SECOND); | ||
const nanos = Math.floor((milliseconds % MILLISECONDS_PER_SECOND) * NANOSECONDS_PER_MILLISECOND); | ||
return { seconds, nanos }; | ||
var seconds = Math.floor(milliseconds / MILLISECONDS_PER_SECOND); | ||
var nanos = Math.floor((milliseconds % MILLISECONDS_PER_SECOND) * NANOSECONDS_PER_MILLISECOND); | ||
return { seconds: seconds, nanos: nanos }; | ||
} | ||
function toMillis(seconds, nanos) { | ||
const secondMillis = seconds * MILLISECONDS_PER_SECOND; | ||
const nanoMillis = nanos / NANOSECONDS_PER_MILLISECOND; | ||
var secondMillis = seconds * MILLISECONDS_PER_SECOND; | ||
var 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 }); | ||
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); | ||
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); | ||
assert_1.default.strictEqual(jsEpochMillisAgain, millisecondsSinceEpoch); | ||
}); | ||
it('converts to and from milliseconds duration', () => { | ||
const durationInMilliseconds = 1234; | ||
const duration = millisecondsToDuration(durationInMilliseconds); | ||
const durationMillisAgain = durationToMilliseconds(duration); | ||
it('converts to and from milliseconds duration', function () { | ||
var durationInMilliseconds = 1234; | ||
var duration = millisecondsToDuration(durationInMilliseconds); | ||
var durationMillisAgain = durationToMilliseconds(duration); | ||
assert_1.default.strictEqual(durationMillisAgain, durationInMilliseconds); | ||
}); | ||
it('converts to and from milliseconds duration (with decimal places)', () => { | ||
const durationInMilliseconds = 3.000161; | ||
const duration = millisecondsToDuration(durationInMilliseconds); | ||
const durationMillisAgain = durationToMilliseconds(duration); | ||
it('converts to and from milliseconds duration (with decimal places)', function () { | ||
var durationInMilliseconds = 3.000161; | ||
var duration = millisecondsToDuration(durationInMilliseconds); | ||
var durationMillisAgain = durationToMilliseconds(duration); | ||
assert_1.default.strictEqual(durationMillisAgain, durationInMilliseconds); | ||
}); | ||
it('adds durations (nanos only)', () => { | ||
const durationA = millisecondsToDuration(100); | ||
const durationB = millisecondsToDuration(200); | ||
const sumDuration = TimeConversion_1.addDurations(durationA, durationB); | ||
it('adds durations (nanos only)', function () { | ||
var durationA = millisecondsToDuration(100); | ||
var durationB = millisecondsToDuration(200); | ||
var sumDuration = TimeConversion_1.addDurations(durationA, durationB); | ||
assert_1.default.deepStrictEqual(sumDuration, new src_1.messages.Duration({ seconds: 0, nanos: 3e8 })); | ||
}); | ||
it('adds durations (seconds only)', () => { | ||
const durationA = millisecondsToDuration(1000); | ||
const durationB = millisecondsToDuration(2000); | ||
const sumDuration = TimeConversion_1.addDurations(durationA, durationB); | ||
it('adds durations (nanos only)', function () { | ||
var durationA = millisecondsToDuration(1000); | ||
var durationB = millisecondsToDuration(2000); | ||
var 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)', () => { | ||
const durationA = millisecondsToDuration(1500); | ||
const durationB = millisecondsToDuration(1600); | ||
const sumDuration = TimeConversion_1.addDurations(durationA, durationB); | ||
it('adds durations (seconds and nanos)', function () { | ||
var durationA = millisecondsToDuration(1500); | ||
var durationB = millisecondsToDuration(1600); | ||
var 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 }); | ||
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({ | ||
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({ | ||
seconds: '123', | ||
@@ -13,0 +13,0 @@ nanos: 456, |
{ | ||
"name": "@cucumber/messages", | ||
"version": "14.1.1", | ||
"version": "14.1.2", | ||
"description": "Protocol Buffer messages for Cucumber's inter-process communication", | ||
@@ -14,7 +14,10 @@ "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", | ||
"prepublishOnly": "tsc --build tsconfig.build.json && copyfiles src/messages.js src/messages.d.ts dist" | ||
"build": "tsc && make src/messages.js && make src/messages.d.ts && copyfiles src/messages.js src/messages.d.ts dist", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
@@ -29,4 +32,15 @@ "dependencies": { | ||
"@types/node": "^14.14.35", | ||
"@typescript-eslint/eslint-plugin": "^4.19.0", | ||
"@typescript-eslint/parser": "^4.19.0", | ||
"copyfiles": "^2.4.1", | ||
"core-js": "^3.9.1", | ||
"eslint": "^7.22.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-react": "^7.23.0", | ||
"mocha": "^8.3.2", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.2.1", | ||
"ts-node": "^9.1.1", | ||
@@ -33,0 +47,0 @@ "typescript": "^4.2.3" |
@@ -14,7 +14,11 @@ 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 | ||
@@ -44,3 +48,5 @@ 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 } | ||
@@ -47,0 +53,0 @@ } |
@@ -42,6 +42,9 @@ 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 (seconds only)', () => { | ||
it('adds durations (nanos only)', () => { | ||
const durationA = millisecondsToDuration(1000) | ||
@@ -51,3 +54,6 @@ const durationB = millisecondsToDuration(2000) | ||
assert.deepStrictEqual(sumDuration, new messages.Duration({ seconds: 3, nanos: 0 })) | ||
assert.deepStrictEqual( | ||
sumDuration, | ||
new messages.Duration({ seconds: 3, nanos: 0 }) | ||
) | ||
}) | ||
@@ -60,4 +66,7 @@ | ||
assert.deepStrictEqual(sumDuration, new messages.Duration({ seconds: 3, nanos: 1e8 })) | ||
assert.deepStrictEqual( | ||
sumDuration, | ||
new messages.Duration({ seconds: 3, nanos: 1e8 }) | ||
) | ||
}) | ||
}) |
{ | ||
"extends": "../../tsconfig.json" | ||
"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/**/*" | ||
] | ||
} |
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
79
20047
1266312
17