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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stringify's options object not actually being optional #4

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/stringify.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { spaces, validIdentifier } from './shared';
import { StringifierOptions } from './interfaces';

export function stringify(value: any, options: StringifierOptions) {
const quote = options.singleQuotes ? "'" : '"';
const indentString = options.spaces ? spaces(options.spaces) : '\t';
export function stringify(value: any, options?: StringifierOptions) {
const quote = (options && options.singleQuotes) ? "'" : '"';
const indentString = (options && options.spaces) ? spaces(options.spaces) : '\t';

return stringifyValue(value, quote, '\n', indentString, true);
}
Expand Down
4 changes: 4 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,10 @@ multi-line string',
assert.equal(stringified, expected);
});
});

it('should be cool with no options object passed in', () => {
fleece.stringify('foo');
})
});

describe('json5 compliance', () => {
Expand Down