Skip to content

Commit d8ec92b

Browse files
committed
First commit
0 parents  commit d8ec92b

File tree

10 files changed

+723
-0
lines changed

10 files changed

+723
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
/node_modules/
3+
/compiled/
4+
/dist/

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
tsconfig.*
2+
/src/
3+
/test/
4+
/compiled/

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Marshaller [![NPM version][npm-image]][npm-url]
2+
> A class that maps between a variety of data types.
3+
4+
## Installation
5+
Simply do: `npm install marshaller`.
6+
7+
## Usage
8+
```typescript
9+
const marshaller = new Marshaller();
10+
11+
marshaller.marshal("true", Boolean); // true
12+
marshaller.marshal("0", Boolean); // false
13+
marshaller.marshal([1, 2, false, true], String); // [ 1, 2, false, true]
14+
marshaller.marshal("Infinity"); // Auto-mapped to number - Infinity.
15+
```
16+
17+
As you can see, you simply pass some arbitrary data and *optionally* the type
18+
you want to map to. If you don't provide any, `Marshaller` will attempt to find
19+
the most appropriate type to map to using heuristics. The second argument, the hint,
20+
accepts either a constructor for a type or a concrete instance of one.
21+
22+
## Changelog:
23+
24+
**v1.0**:
25+
26+
- First release.
27+
28+
[npm-url]: https://npmjs.org/package/marshaller
29+
[npm-image]: https://badge.fury.io/js/marshaller.svg

package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "marshaller",
3+
"version": "1.0.0",
4+
"description": "A class that maps between a variety of data types.",
5+
"main": "./dist/cjs/index.js",
6+
"module": "./dist/es2015/index.js",
7+
"browser": "./dist/es2015/index.js",
8+
"types": "./dist/es2015/index.d.ts",
9+
"typings": "./dist/es2015/index.d.ts",
10+
"scripts": {
11+
"build:pre": "mkdir -p dist/cjs/interface && mkdir -p dist/es2015/interface",
12+
"build:cjs": "tsc --module commonjs --outDir dist/cjs -p tsconfig.dist.json",
13+
"build:es2015": "tsc --module es2015 --outDir dist/es2015 -p tsconfig.dist.json",
14+
"build": "npm run build:pre && npm run build:cjs && npm run build:es2015",
15+
"test:pre": "tsc --module commonjs --target es2017 --sourceMap",
16+
"test": "NODE_ENV=TEST npm run test:pre && ava --verbose"
17+
},
18+
"keywords": [
19+
"marshaller",
20+
"marshalling",
21+
"mapping",
22+
"type casting"
23+
],
24+
"author": "Frederik Wessberg",
25+
"license": "MIT",
26+
"devDependencies": {
27+
"ava": "^0.19.1",
28+
"typescript": "2.3.0"
29+
},
30+
"dependencies": {
31+
"typedetector": "file:../TypeDetector"
32+
}
33+
}

0 commit comments

Comments
 (0)