Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript rewrite #5

Merged
merged 27 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4406c86
Begin Typescript rewrite
Sep 3, 2020
74597ed
Roll testing framework
Sep 3, 2020
c815849
conform to prettier standard
Sep 3, 2020
99aa799
REmove dup property from bower
Sep 3, 2020
11434b3
remove var
Sep 3, 2020
3f81f1a
Add nyc support
Sep 3, 2020
208c3f1
Add compiler support and remove grunt deps
Sep 3, 2020
a01c8b4
add fix for negative zero
Sep 3, 2020
3b5c5ac
Port test case array from qunit to mocha
Sep 3, 2020
109db80
Port remaining qunit tests
Sep 3, 2020
5d37e27
Add feat. and tests for open issues on cbor-js
Sep 3, 2020
3fee2f0
Add documentation
Sep 3, 2020
208a69b
Update prettier ignore file
aaronhuggins Sep 3, 2020
f8a7f2a
Add mod.ts for deno support
aaronhuggins Sep 3, 2020
4213c62
Ignore mod.ts for deno
aaronhuggins Sep 3, 2020
e00c528
Update naming offunction types
aaronhuggins Sep 3, 2020
e992cd8
Refactor exports
aaronhuggins Sep 3, 2020
f0d8052
Add jsdoc comments and improved typing
aaronhuggins Sep 3, 2020
e025e27
Regenerate docs
aaronhuggins Sep 3, 2020
96102c7
Add polyfill support for window polluters.
aaronhuggins Sep 3, 2020
2120389
Enhance polluting the global scope
aaronhuggins Sep 3, 2020
6a8e8a3
Remove deprecated javascript
aaronhuggins Sep 3, 2020
3bd1996
Add test for polyfill pollution
aaronhuggins Sep 3, 2020
9b10b57
Restructure tests in prep for deno testing
aaronhuggins Sep 3, 2020
33b94a2
Complete test coverage for both deno and node
aaronhuggins Sep 3, 2020
4691758
Update documentation
aaronhuggins Sep 3, 2020
8bcd643
Add sonarcloud and codecov to repo
aaronhuggins Sep 3, 2020
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
bower_components
.nyc_output
coverage
node_modules
dist
esm

cbor-js.zip
cbor.min.js
Expand Down
9 changes: 9 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recursive": "./test",
"extension": ["ts"],
"require": ["ts-node/register", "source-map-support/register"],
"exclude": ["test/DenoMochaCBOR.ts"],
"reporter": ["spec"],
"full-trace": true,
"bail": false
}
8 changes: 8 additions & 0 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"all": true,
"include": ["src/*.ts"],
"require": ["source-map-support/register"],
"check-coverage": false,
"reporter": "lcov"
}
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.nyc_output
coverage
dist
docs
esm
test/tests.js
test/*.html
cbor.js
Gruntfile.js
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "printWidth": 120 }
2 changes: 2 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sonar.source=src/CBOR.ts,src/polyfill.ts
sonar.exclusions=docs/**,test/**,mod.ts
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.tabSize": 2
}
168 changes: 0 additions & 168 deletions Gruntfile.js

This file was deleted.

3 changes: 2 additions & 1 deletion LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) 2014 Patrick Gansterer <[email protected]>
Copyright (c) 2014-2016 Patrick Gansterer <[email protected]>
Copyright (c) 2020-present Aaron Huggins <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
73 changes: 47 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,67 @@
cbor-js
=======
# cbor-redux

The Concise Binary Object Representation (CBOR) data format ([RFC 7049](http://tools.ietf.org/html/rfc7049)) implemented in pure JavaScript.
The Concise Binary Object Representation (CBOR) data format ([RFC 7049](http://tools.ietf.org/html/rfc7049)) implemented in pure JavaScript, revived.

[![Build Status](https://api.travis-ci.org/paroga/cbor-js.svg)](https://travis-ci.org/paroga/cbor-js)
[![Coverage Status](https://coveralls.io/repos/paroga/cbor-js/badge.svg?branch=master)](https://coveralls.io/r/paroga/cbor-js?branch=master)
[![Dependency status](https://david-dm.org/paroga/cbor-js/status.svg)](https://david-dm.org/paroga/cbor-js#info=dependencies&view=table)
[![Dev Dependency Status](https://david-dm.org/paroga/cbor-js/dev-status.svg)](https://david-dm.org/paroga/cbor-js#info=devDependencies&view=table)
[![Selenium Test Status](https://saucelabs.com/buildstatus/paroga-cbor-js)](https://saucelabs.com/u/paroga-cbor-js)
Rewritten in TypeScript for the browser, Deno, and Node.

[![Selenium Test Status](https://saucelabs.com/browser-matrix/paroga-cbor-js.svg)](https://saucelabs.com/u/paroga-cbor-js)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/standard/eslint-config-standard-with-typescript)
[![codecov](https://codecov.io/gh/aaronhuggins/cbor-redux/branch/master/graph/badge.svg)](https://codecov.io/gh/aaronhuggins/cbor-redux)
![GitHub last commit](https://img.shields.io/github/last-commit/aaronhuggins/cbor-redux)
![GitHub contributors](https://img.shields.io/github/contributors/aaronhuggins/cbor-redux)
![npm collaborators](https://img.shields.io/npm/collaborators/cbor-redux)<br />
![GitHub top language](https://img.shields.io/github/languages/top/aaronhuggins/cbor-redux)
![npm bundle size](https://img.shields.io/bundlephobia/min/cbor-redux)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/aaronhuggins/cbor-redux)
![npm](https://img.shields.io/npm/dw/cbor-redux)
![NPM](https://img.shields.io/npm/l/cbor-redux)<br />
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=aaronhuggins_cbor-redux&metric=alert_status)](https://sonarcloud.io/dashboard?id=aaronhuggins_cbor-redux)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=aaronhuggins_cbor-redux&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=aaronhuggins_cbor-redux)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=aaronhuggins_cbor-redux&metric=security_rating)](https://sonarcloud.io/dashboard?id=aaronhuggins_cbor-redux)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=aaronhuggins_cbor-redux&metric=ncloc)](https://sonarcloud.io/dashboard?id=aaronhuggins_cbor-redux)

API
---
## Usage

The `CBOR`-object provides the following two functions:

CBOR.**decode**(*data*)
> Take the ArrayBuffer object *data* and return it decoded as a JavaScript object.

CBOR.**encode**(*data*)
> Take the JavaScript object *data* and return it encoded as a ArrayBuffer object.
Require `cbor-redux` in Node:
```javascript
const { CBOR } = require('cbor-redux')
```

Usage
-----
or import in Deno:
```javascript
import { CBOR } from 'https://deno.land/x/[email protected]'
```

Include `cbor.js` in your or HTML page:
or script on an HTML page:
```html
<script src="path/to/cbor.js" type="text/javascript"></script>
<script src="https://cdn.skypack.dev/cbor-redux@^0.2.0" type="text/javascript"></script>
```

Then you can use it via the `CBOR`-object in your code:

```javascript
var initial = { Hello: "World" };
var encoded = CBOR.encode(initial);
var decoded = CBOR.decode(encoded);
const initial = { Hello: 'World' }
const encoded = CBOR.encode(initial)
const decoded = CBOR.decode(encoded)
```

After running this example `initial` and `decoded` represent the same value.

### Combination with WebSocket
## API

The `CBOR`-object provides the following two functions:

- **CBOR**._**decode**_(_data: ArrayBuffer_)
> Take the ArrayBuffer object _data_ and return it decoded as a JavaScript object.

- **CBOR**._**encode**_(_data: any_)
> Take the JavaScript object _data_ and return it encoded as a ArrayBuffer object.

For complete API details, visit the [documentation](https://aaronhuggins.github.io/cbor-redux/).

## Combination with WebSocket

The API was designed to play well with the `WebSocket` object in the browser:

```javascript
var websocket = new WebSocket(url);
websocket.binaryType = "arraybuffer";
Expand Down
24 changes: 0 additions & 24 deletions bower.json

This file was deleted.

Loading