-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: bigint is used for all Int64/UInt64 fields now. Type defs have also changed slightly.
- Loading branch information
1 parent
de51e1d
commit 78dc139
Showing
13 changed files
with
9,457 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,58 @@ | ||
# typescript-library-skeleton | ||
# @jcoreio/sparkplug-payload | ||
|
||
[![CircleCI](https://circleci.com/gh/jedwards1211/typescript-library-skeleton.svg?style=svg)](https://circleci.com/gh/jedwards1211/typescript-library-skeleton) | ||
[![Coverage Status](https://codecov.io/gh/jedwards1211/typescript-library-skeleton/branch/master/graph/badge.svg)](https://codecov.io/gh/jedwards1211/typescript-library-skeleton) | ||
[![CircleCI](https://circleci.com/gh/jcoreio/sparkplug-payload.svg?style=svg)](https://circleci.com/gh/jcoreio/sparkplug-payload) | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) | ||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
[![npm version](https://badge.fury.io/js/typescript-library-skeleton.svg)](https://badge.fury.io/js/typescript-library-skeleton) | ||
[![npm version](https://badge.fury.io/js/%40jcoreio%2Fsparkplug-payload.svg)](https://badge.fury.io/js/%40jcoreio%2Fsparkplug-payload) | ||
|
||
This is my personal skeleton for creating an typescript library npm package. You are welcome to use it. | ||
A library that provides tools for encoding and decoding payload objects using | ||
the Sparkplug Google Protocol Buffer Schema described in the Sparkplug | ||
Specification from Cirrus Link Solutions. | ||
|
||
## Quick start | ||
https://s3.amazonaws.com/cirrus-link-com/Sparkplug+Topic+Namespace+and+State+ManagementV2.1+Apendix++Payload+B+format.pdf | ||
|
||
**Not a drop-in replacement for the original `sparkplug-payload` package; require paths have changed.** | ||
|
||
## Installation | ||
|
||
```sh | ||
npx 0-60 clone https://github.com/jedwards1211/typescript-library-skeleton.git | ||
npm install --save @jcoreio/sparkplug-payload | ||
``` | ||
|
||
## Tools used | ||
|
||
- babel 7 | ||
- typescript | ||
- mocha | ||
- chai | ||
- istanbul | ||
- nyc | ||
- eslint | ||
- prettier | ||
- husky | ||
- semantic-release | ||
- renovate | ||
- Circle CI | ||
- Codecov.io | ||
### Encoding a payload | ||
|
||
Here is a code example of encoding a payload: | ||
|
||
```javascript | ||
var sparkplug = require('sparkplug-payload/spBv1.0'), | ||
payload = { | ||
timestamp: new Date().getTime(), | ||
metrics: [ | ||
{ | ||
name: 'intMetric', | ||
value: 1, | ||
type: 'Int32', | ||
}, | ||
], | ||
}, | ||
encoded = sparkplug.encodePayload(payload) | ||
``` | ||
|
||
### Decoding a payload | ||
|
||
Here is a code example of decoding an encoded payload: | ||
|
||
```javascript | ||
var decoded = sparkplug.decodePayload(encoded) | ||
``` | ||
|
||
## License | ||
|
||
Copyright (c) 2017 Cirrus Link Solutions | ||
|
||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
|
||
Contributors: Cirrus Link Solutions, JCore Systems |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// flow-typed signature: 7d695f62b25d736b51c93b05bb31ffd8 | ||
// flow-typed version: cc44a27e8f/long_v4.x.x/flow_>=v0.104.x | ||
|
||
declare module 'long' { | ||
declare class Long { | ||
constructor(low: number, high: number, unsigned?: boolean): Long; | ||
|
||
// Fields | ||
low: number; | ||
high: number; | ||
unsigned: boolean; | ||
|
||
// Methods | ||
toNumber(): number; | ||
add(addend: Long | number | string): Long; | ||
and(other: Long | number | string): Long; | ||
compare(other: Long | number | string): number; | ||
comp(other: Long | number | string): number; | ||
divide(divisor: Long | number | string): Long; | ||
div(divisor: Long | number | string): Long; | ||
equals(other: Long | number | string): boolean; | ||
eq(other: Long | number | string): boolean; | ||
getHighBits(): number; | ||
getHighBitsUnsigned(): number; | ||
getLowBits(): number; | ||
getLowBitsUnsigned(): number; | ||
getNumBitsAbs(): number; | ||
greaterThan(other: Long | number | string): boolean; | ||
gt(other: Long | number | string): boolean; | ||
greaterThanOrEqual(other: Long | number | string): boolean; | ||
gte(other: Long | number | string): boolean; | ||
ge(other: Long | number | string): boolean; | ||
isEven(): boolean; | ||
isNegative(): boolean; | ||
isOdd(): boolean; | ||
isPositive(): boolean; | ||
isZero(): boolean; | ||
eqz(): boolean; | ||
lessThan(other: Long | number | string): boolean; | ||
lt(other: Long | number | string): boolean; | ||
lessThanOrEqual(other: Long | number | string): boolean; | ||
lte(other: Long | number | string): boolean; | ||
le(other: Long | number | string): boolean; | ||
modulo(divisor: Long | number | string): Long; | ||
mod(divisor: Long | number | string): Long; | ||
rem(divisor: Long | number | string): Long; | ||
multiply(multiplier: Long | number | string): Long; | ||
mul(multiplier: Long | number | string): Long; | ||
negate(): Long; | ||
neg(): Long; | ||
not(): Long; | ||
notEquals(other: Long | number | string): boolean; | ||
neq(other: Long | number | string): boolean; | ||
ne(other: Long | number | string): boolean; | ||
or(other: Long | number | string): Long; | ||
shiftLeft(numBits: Long | number | string): Long; | ||
shl(numBits: Long | number | string): Long; | ||
shiftRight(numBits: Long | number | string): Long; | ||
shr(numBits: Long | number | string): Long; | ||
shiftRightUnsigned(numBits: Long | number | string): Long; | ||
shru(numBits: Long | number | string): Long; | ||
shr_u(numBits: Long | number | string): Long; | ||
subtract(subtrahend: Long | number | string): Long; | ||
sub(subtrahend: Long | number | string): Long; | ||
toBytes(le?: boolean): number[]; | ||
toBytesLE(): number[]; | ||
toBytesBE(): number[]; | ||
toInt(): number; | ||
toNumber(): number; | ||
toSigned(): Long; | ||
// TODO: fix this. Uncommenting will break spreading for some reason... (e.g. {...new Long(1)}) | ||
// toString(radix?: number): string; | ||
toUnsigned(): Long; | ||
xor(other: Long | number | string): Long; | ||
|
||
// Constants | ||
static ZERO: Long; | ||
static ONE: Long; | ||
static NEG_ONE: Long; | ||
static UZERO: Long; | ||
static UONE: Long; | ||
static MAX_VALUE: Long; | ||
static MIN_VALUE: Long; | ||
static MAX_UNSIGNED_VALUE: Long; | ||
|
||
// Static methods | ||
static isLong(obj: mixed): boolean; | ||
static fromBits( | ||
lowBits: number, | ||
highBits: number, | ||
unsigned?: boolean | ||
): Long; | ||
static fromBytes(bytes: number[], unsigned?: boolean, le?: boolean): Long; | ||
static fromBytesLE(bytes: number[], unsigned?: boolean): Long; | ||
static fromBytesBE(bytes: number[], unsigned?: boolean): Long; | ||
static fromInt(value: number, unsigned?: boolean): Long; | ||
static fromNumber(value: number, unsigned?: boolean): Long; | ||
static fromString(str: string, unsigned?: boolean, radix?: number): Long; | ||
static fromString(str: string, radix: number): Long; | ||
static fromValue(val: mixed, unsigned?: boolean): Long; | ||
} | ||
|
||
declare module.exports: typeof Long | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Oops, something went wrong.