Skip to content

Commit

Permalink
update dependencies, use yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
CaselIT committed May 9, 2020
1 parent fd21ced commit 9406c8a
Show file tree
Hide file tree
Showing 10 changed files with 2,888 additions and 54 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ build
coverage
typings
test_bundle.js
.nyc_output
*.log
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
language: node_js
node_js:
- "6"
- "5"
- "4"
matrix:
allow_failures:
- node_js: "4"
before_script: npm run typings
after_success: npm run coveralls
- "14"
- "12"
- "10"
after_success:
- yarn test-cover
- yarn coverage
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
[![Build Status](https://travis-ci.org/CaselIT/json-set-map.svg?branch=master)](https://travis-ci.org/CaselIT/json-set-map)
[![Coverage Status](https://coveralls.io/repos/github/CaselIT/json-set-map/badge.svg?branch=master)](https://coveralls.io/github/CaselIT/json-set-map?branch=master)
# json-set-map
`Set` and `Map` classes extended with the method `toJSON` and a static `fromJSON`.
`Set` and `Map` extension that support JSON serialization and de-serialization

The original `Set` and `Map` object are not modified, so can still be used.

This library does not provides pilifills for Set and Map.
This library does not provides polyfills for Set and Map.

## Install
```sh
npm i json-set-map
yarn add json-set-map
```
The current version supports `node v6.x` and `v5.x`. Tested on browsers `Chrome v52+`, `Firefox v47+` and `Edge v38+`
The current version supports `node v6.x+` and modern browsers.

## Usage
* Typescript and es6
Expand Down Expand Up @@ -91,13 +91,9 @@ Static method useful to load a `Set` or `Map` from the object returned by `JSON.
Refer to the JSDoc documentation on the files for mode details.

#### Node
JSON does not support `undefined` and is replaced with `null`. This prevents the correct deserialization of a Set with both `undefined` and `null` as element or of a Map with both element as key.
JSON does not support `undefined` and is replaced with `null`. This prevents the correct de-serialization of a Set with both `undefined` and `null` as element or of a Map with both element as key.

```ts
const str = JSON.stringify(new jSet().add(null).add(undefined)) // => '[null,null]'
jSet.fromJSON(JSON.parse(str)) // => SerializableSet { null }
```


### TODO
* Add support for `node v4.x`
47 changes: 25 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
{
"name": "json-set-map",
"version": "1.0.2",
"description": "Set and map classes extended with the methods toJSON and a static fromJSON",
"version": "1.1.0",
"description": "Set and map extension that support JSON serialization and de-serialization",
"main": "build/index.js",
"typings": "build/index.d.ts",
"dependencies": {},
"devDependencies": {
"browserify": "^13.1.0",
"coveralls": "^2.11.14",
"istanbul": "^0.4.5",
"tap-spec": "^4.1.1",
"tape": "^4.6.0",
"tslint": "^3.15.1",
"typescript": "^2.0.3",
"typings": "^1.4.0"
"@types/tape": "^4.13.0",
"browserify": "^16.5.1",
"coveralls": "^3.1.0",
"nyc": "^15.0.1",
"tap-nyc": "^1.0.3",
"tap-spec": "^5.0.0",
"tape": "^5.0.0",
"tslint": "^6.1.2",
"typescript": "^3.8.3"
},
"scripts": {
"prebrowserify": "tsc",
"browserify": "browserify build/test/map.spec.js build/test/set.spec.js > ./test/test_bundle.js",
"cover": "istanbul cover node_modules/tape/bin/tape build/test/**/*.spec.js",
"coveralls": "npm run cover -- --report lcovonly | tap-spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"prebrowser": "tsc",
"browser": "browserify build/test/map.spec.js build/test/set.spec.js > test/test_bundle.js",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"pretest": "tsc",
"test": "tape build/test/**/*.spec.js | tap-spec",
"tslint": "tslint index.ts ./test/**/.ts ./src/**/*.ts",
"typings": "typings i"
"test-cover": "nyc tape build/test/**/*.spec.js | tap-nyc",
"tslint": "tslint index.ts ./test/**/.ts ./src/**/*.ts"
},
"author": "Federico Caselli",
"license": "MIT",
"keywords": [
"Set",
"Map",
"ES6",
"toJSON",
"fromJSON",
"JSON",
"serialize",
"deserialize",
"serialization",
"deserialization"
"de-serialization"
],
"repository": {
"type": "git",
Expand All @@ -50,10 +48,15 @@
"build/index*",
"build/src/**/*",
"LICENSE",
"README.md",
"typings.json"
"README.md"
],
"engines": {
"node": ">=5.x"
"node": ">=8.x"
},
"nyc": {
"reporter": [
"html",
"text"
]
}
}
2 changes: 1 addition & 1 deletion src/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class SerializableMap<K, V> extends Map<K, V> {
return [...this.entries()];
}
/**
* Creates a new map instance from the array of tuple returned by JSON.parse.
* Creates a new map instance from the array of tuple returned by JSON.parse.
* If no parser is specified, this method returns `new SerializableMap<K, V>(iterable)`
* @param {any[]} iterable The array of tuples.
* @param {(item: any) => K} [options.keyParser] Function to use as parser for the key objects.
Expand Down
2 changes: 1 addition & 1 deletion src/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class SerializableSet<T> extends Set<T> {
return [...this.values()];
}
/**
* Creates a new set instance from the array returned by JSON.parse.
* Creates a new set instance from the array returned by JSON.parse.
* If no parser is specified, this method returns `new SerializableSet<T>(iterable)`
* @param {any[]} iterable The array of elements.
* @param {(item: any) => T} [options.parser] Function to use as parser for the objects.
Expand Down
2 changes: 1 addition & 1 deletion test/spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</head>
<body>
<h3>Json set map test.</h3>
Run <code>npm run browserify</code> to create the bundle used to run the test.
Run <code>yarn browser</code> to create the bundle used to run the test.
<br>
Open the console to see the tests.
<script type="text/javascript" src="./test_bundle.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"noUnusedParameters": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"strictNullChecks": true
"strictNullChecks": true,
"strict": true
},
"files": [
"index.ts",
"typings/index.d.ts",
"test/map.spec.ts",
"test/set.spec.ts"
]
Expand Down
10 changes: 0 additions & 10 deletions typings.json

This file was deleted.

Loading

0 comments on commit 9406c8a

Please sign in to comment.