Skip to content

Commit

Permalink
feat: add bigint support (#41)
Browse files Browse the repository at this point in the history
* feat: add bigint support

* style: update linter to support ES2020

* style: lint --fix
  • Loading branch information
keithamus authored Mar 1, 2021
1 parent c66dc49 commit fcfc58d
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 20,744 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import inspectDate from './lib/date'
import inspectFunction from './lib/function'
import inspectMap from './lib/map'
import inspectNumber from './lib/number'
import inspectBigInt from './lib/bigint'
import inspectRegExp from './lib/regexp'
import inspectSet from './lib/set'
import inspectString from './lib/string'
Expand Down Expand Up @@ -47,6 +48,9 @@ const baseTypesMap = {
number: inspectNumber,
Number: inspectNumber,

bigint: inspectBigInt,
BigInt: inspectBigInt,

string: inspectString,
String: inspectString,

Expand Down
7 changes: 7 additions & 0 deletions lib/bigint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { truncate, truncator } from './helpers'

export default function inspectBigInt(number, options) {
let nums = truncate(number.toString(), options.truncate - 1)
if (nums !== truncator) nums += 'n'
return options.stylize(nums, 'bigint')
}
1 change: 1 addition & 0 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const ansiColors = {
const styles = {
special: 'cyan',
number: 'yellow',
bigint: 'yellow',
boolean: 'yellow',
undefined: 'grey',
null: 'bold',
Expand Down
Loading

0 comments on commit fcfc58d

Please sign in to comment.