Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
node_modules
Thumbs.db
.DS_Store
.DS_Store
index.js
index.d.ts
.idea
yarn.lock
package-lock.json
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
language: node_js
node_js:
- 4.4.7
- 5
- 6
- 10
13 changes: 0 additions & 13 deletions index.js

This file was deleted.

13 changes: 13 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Stringify object values
* { hello: 'world' } -> { hello: "'world'" }
*
* @param {object} object
* @return {object}
*/
export = (function stringify(object: { [x: string]: any; }) {
return Object.keys(object)
.reduce(function (previous: any, next: any) {
return (previous[next] = JSON.stringify(object[next]), previous);
}, {}) as {[x: string]: string};
});
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"description": "Stringify object values",
"main": "index.js",
"scripts": {
"test": "mocha test.js"
"build": "tsc",
"prepublish": "tsc",
"test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'test.ts'"
},
"repository": {
"type": "git",
Expand All @@ -19,7 +21,12 @@
"author": "Kier Borromeo <seraphipod@gmail.com> (http://srph.github.io)",
"license": "ISC",
"devDependencies": {
"chai": "^3.5.0",
"mocha": "^3.0.2"
}
"@types/chai": "^4.2.12",
"@types/mocha": "^8.0.0",
"chai": "^4.2.0",
"mocha": "^8.0.1",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
},
"files": ["index.js", "index.d.ts"]
}
22 changes: 0 additions & 22 deletions test.js

This file was deleted.

21 changes: 21 additions & 0 deletions test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as chai from "chai";
import stringify from "./";
var expect = chai.expect;
describe('stringify', function () {
it('should stringify each of the object\'s value', function () {
var test = {
hello: 'world',
favorite: 1,
equation: '1+1',
random: {},
arr: []
};
expect(stringify(test)).to.eql({
hello: JSON.stringify('world'),
favorite: JSON.stringify(1),
equation: JSON.stringify('1+1'),
random: JSON.stringify({}),
arr: JSON.stringify([])
});
});
});
21 changes: 21 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "es5",
"module": "CommonJS",
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noUnusedLocals": true,
"pretty": true,
"declaration": true,
"lib": [
"esnext"
],
},
"files": [
"index.ts"
]
}