| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7fb4794 commit 2e05e65
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + module.exports.isObject = (obj) => obj.constructor === Object; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,32 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + // Refs: https://github.com/nodejs/node/issues/7788 | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const path = require('path'); | ||
| 6 | + const repl = require('repl'); | ||
| 7 | + const stream = require('stream'); | ||
| 8 | + const inputStream = new stream.PassThrough(); | ||
| 9 | + const outputStream = new stream.PassThrough(); | ||
| 10 | + const fixture = path.join(common.fixturesDir, 'is-object.js'); | ||
| 11 | + const r = repl.start({ | ||
| 12 | + input: inputStream, | ||
| 13 | + output: outputStream, | ||
| 14 | + useGlobal: false | ||
| 15 | + }); | ||
| 16 | + | ||
| 17 | + let output = ''; | ||
| 18 | + outputStream.setEncoding('utf8'); | ||
| 19 | + outputStream.on('data', (data) => output += data); | ||
| 20 | + | ||
| 21 | + r.on('exit', common.mustCall(() => { | ||
| 22 | + const results = output.split('\n').map((line) => { | ||
| 23 | + return line.replace(/\w*>\w*/, '').trim(); | ||
| 24 | + }); | ||
| 25 | + | ||
| 26 | + assert.deepStrictEqual(results, ['undefined', 'true', 'true', '']); | ||
| 27 | + })); | ||
| 28 | + | ||
| 29 | + inputStream.write('const isObject = (obj) => obj.constructor === Object;\n'); | ||
| 30 | + inputStream.write('isObject({});\n'); | ||
| 31 | + inputStream.write(`require('${fixture}').isObject({});\n`); | ||
| 32 | + r.close(); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments