1 | var strict = require('./modes/strict');
|
2 |
|
3 | var OBJECT_REGEX = /\[object (\w+)\]/;
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | module.exports.type = function type(value) {
|
12 | if (value && value._bsontype) {
|
13 | return value._bsontype;
|
14 | }
|
15 | return OBJECT_REGEX.exec(Object.prototype.toString.call(value))[1];
|
16 | };
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | module.exports.special = {
|
22 | types: Object.keys(strict.serialize),
|
23 | keys: Object.keys(strict.deserialize)
|
24 | };
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | module.exports.isSpecial = function isSpecial(value) {
|
32 | return module.exports.special.types.indexOf(module.exports.type(value)) > -1;
|
33 | };
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | module.exports.isObject = function isObject(value) {
|
41 | return module.exports.type(value) === 'Object';
|
42 | };
|