mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 18:52:50 +00:00
Added files
This commit is contained in:
5
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/.travis.yml
generated
vendored
Normal file
5
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
- 0.8
|
||||
- 0.9 # development version of 0.8, may be unstable
|
||||
19
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/Makefile
generated
vendored
Normal file
19
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/Makefile
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
NODE = node
|
||||
NPM = npm
|
||||
NODEUNIT = node_modules/nodeunit/bin/nodeunit
|
||||
|
||||
all: clean node_gyp
|
||||
|
||||
test: clean node_gyp
|
||||
npm test
|
||||
|
||||
node_gyp: clean
|
||||
node-gyp configure build
|
||||
|
||||
clean:
|
||||
node-gyp clean
|
||||
|
||||
browserify:
|
||||
node_modules/.bin/onejs build browser_build/package.json browser_build/bson.js
|
||||
|
||||
.PHONY: all
|
||||
1
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/README.md
generated
vendored
Normal file
1
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/README.md
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
A JS/C++ Bson parser for node, used in the MongoDB Native driver
|
||||
130
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/benchmarks/benchmarks.js
generated
vendored
Normal file
130
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/benchmarks/benchmarks.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
// var BSON = require('../../lib/mongodb').BSONNative.BSON,
|
||||
// ObjectID = require('../../lib/mongodb').BSONNative.ObjectID,
|
||||
// Code = require('../../lib/mongodb').BSONNative.Code,
|
||||
// Long = require('../../lib/mongodb').BSONNative.Long,
|
||||
// Binary = require('../../lib/mongodb').BSONNative.Binary,
|
||||
// debug = require('util').debug,
|
||||
// inspect = require('util').inspect,
|
||||
//
|
||||
// Long = require('../../lib/mongodb').Long,
|
||||
// ObjectID = require('../../lib/mongodb').ObjectID,
|
||||
// Binary = require('../../lib/mongodb').Binary,
|
||||
// Code = require('../../lib/mongodb').Code,
|
||||
// DBRef = require('../../lib/mongodb').DBRef,
|
||||
// Symbol = require('../../lib/mongodb').Symbol,
|
||||
// Double = require('../../lib/mongodb').Double,
|
||||
// MaxKey = require('../../lib/mongodb').MaxKey,
|
||||
// MinKey = require('../../lib/mongodb').MinKey,
|
||||
// Timestamp = require('../../lib/mongodb').Timestamp;
|
||||
|
||||
|
||||
// var BSON = require('../../lib/mongodb').BSONPure.BSON,
|
||||
// ObjectID = require('../../lib/mongodb').BSONPure.ObjectID,
|
||||
// Code = require('../../lib/mongodb').BSONPure.Code,
|
||||
// Long = require('../../lib/mongodb').BSONPure.Long,
|
||||
// Binary = require('../../lib/mongodb').BSONPure.Binary;
|
||||
|
||||
var BSON = require('../lib/bson').BSONNative.BSON,
|
||||
Long = require('../lib/bson').Long,
|
||||
ObjectID = require('../lib/bson').ObjectID,
|
||||
Binary = require('../lib/bson').Binary,
|
||||
Code = require('../lib/bson').Code,
|
||||
DBRef = require('../lib/bson').DBRef,
|
||||
Symbol = require('../lib/bson').Symbol,
|
||||
Double = require('../lib/bson').Double,
|
||||
MaxKey = require('../lib/bson').MaxKey,
|
||||
MinKey = require('../lib/bson').MinKey,
|
||||
Timestamp = require('../lib/bson').Timestamp;
|
||||
|
||||
// console.dir(require('../lib/bson'))
|
||||
|
||||
var COUNT = 1000;
|
||||
var COUNT = 100;
|
||||
|
||||
var object = {
|
||||
string: "Strings are great",
|
||||
decimal: 3.14159265,
|
||||
bool: true,
|
||||
integer: 5,
|
||||
date: new Date(),
|
||||
double: new Double(1.4),
|
||||
id: new ObjectID(),
|
||||
min: new MinKey(),
|
||||
max: new MaxKey(),
|
||||
symbol: new Symbol('hello'),
|
||||
long: Long.fromNumber(100),
|
||||
bin: new Binary(new Buffer(100)),
|
||||
|
||||
subObject: {
|
||||
moreText: "Bacon ipsum dolor sit amet cow pork belly rump ribeye pastrami andouille. Tail hamburger pork belly, drumstick flank salami t-bone sirloin pork chop ribeye ham chuck pork loin shankle. Ham fatback pork swine, sirloin shankle short loin andouille shank sausage meatloaf drumstick. Pig chicken cow bresaola, pork loin jerky meatball tenderloin brisket strip steak jowl spare ribs. Biltong sirloin pork belly boudin, bacon pastrami rump chicken. Jowl rump fatback, biltong bacon t-bone turkey. Turkey pork loin boudin, tenderloin jerky beef ribs pastrami spare ribs biltong pork chop beef.",
|
||||
longKeylongKeylongKeylongKeylongKeylongKey: "Pork belly boudin shoulder ribeye pork chop brisket biltong short ribs. Salami beef pork belly, t-bone sirloin meatloaf tail jowl spare ribs. Sirloin biltong bresaola cow turkey. Biltong fatback meatball, bresaola tail shankle turkey pancetta ham ribeye flank bacon jerky pork chop. Boudin sirloin shoulder, salami swine flank jerky t-bone pork chop pork beef tongue. Bresaola ribeye jerky andouille. Ribeye ground round sausage biltong beef ribs chuck, shank hamburger chicken short ribs spare ribs tenderloin meatloaf pork loin."
|
||||
},
|
||||
|
||||
subArray: [1,2,3,4,5,6,7,8,9,10],
|
||||
anotherString: "another string",
|
||||
code: new Code("function() {}", {i:1})
|
||||
}
|
||||
|
||||
// Number of objects
|
||||
var numberOfObjects = 10000;
|
||||
var bson = new BSON([Long, ObjectID, Binary, Code, DBRef, Symbol, Double, Timestamp, MaxKey, MinKey]);
|
||||
console.log("---------------------- 1")
|
||||
var s = new Date()
|
||||
// Object serialized
|
||||
for(var i = 0; i < numberOfObjects; i++) {
|
||||
objectBSON = bson.serialize(object, null, true)
|
||||
}
|
||||
console.log("====================== " + (new Date().getTime() - s.getTime()) + " :: " + ((new Date().getTime() - s.getTime()))/numberOfObjects)
|
||||
|
||||
console.log("---------------------- 2")
|
||||
var s = new Date()
|
||||
// Object serialized
|
||||
for(var i = 0; i < numberOfObjects; i++) {
|
||||
bson.deserialize(objectBSON);
|
||||
}
|
||||
console.log("====================== " + (new Date().getTime() - s.getTime()) + " :: " + ((new Date().getTime() - s.getTime()))/numberOfObjects)
|
||||
|
||||
// // Buffer With copies of the objectBSON
|
||||
// var data = new Buffer(objectBSON.length * numberOfObjects);
|
||||
// var index = 0;
|
||||
//
|
||||
// // Copy the buffer 1000 times to create a strea m of objects
|
||||
// for(var i = 0; i < numberOfObjects; i++) {
|
||||
// // Copy data
|
||||
// objectBSON.copy(data, index);
|
||||
// // Adjust index
|
||||
// index = index + objectBSON.length;
|
||||
// }
|
||||
//
|
||||
// // console.log("-----------------------------------------------------------------------------------")
|
||||
// // console.dir(objectBSON)
|
||||
//
|
||||
// var x, start, end, j
|
||||
// var objectBSON, objectJSON
|
||||
//
|
||||
// // Allocate the return array (avoid concatinating everything)
|
||||
// var results = new Array(numberOfObjects);
|
||||
//
|
||||
// console.log(COUNT + "x (objectBSON = BSON.serialize(object))")
|
||||
// start = new Date
|
||||
//
|
||||
// // var objects = BSON.deserializeStream(data, 0, numberOfObjects);
|
||||
// // console.log("----------------------------------------------------------------------------------- 0")
|
||||
// // var objects = BSON.deserialize(data);
|
||||
// // console.log("----------------------------------------------------------------------------------- 1")
|
||||
// // console.dir(objects)
|
||||
//
|
||||
// for (j=COUNT; --j>=0; ) {
|
||||
// var nextIndex = BSON.deserializeStream(data, 0, numberOfObjects, results, 0);
|
||||
// }
|
||||
//
|
||||
// end = new Date
|
||||
// var opsprsecond = COUNT / ((end - start)/1000);
|
||||
// console.log("bson size (bytes): ", objectBSON.length);
|
||||
// console.log("time = ", end - start, "ms -", COUNT / ((end - start)/1000), " ops/sec");
|
||||
// console.log("MB/s = " + ((opsprsecond*objectBSON.length)/1024));
|
||||
//
|
||||
// // console.dir(nextIndex)
|
||||
// // console.dir(results)
|
||||
|
||||
|
||||
17
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/binding.gyp
generated
vendored
Normal file
17
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/binding.gyp
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'bson',
|
||||
'sources': [ 'ext/bson.cc' ],
|
||||
'cflags!': [ '-fno-exceptions' ],
|
||||
'cflags_cc!': [ '-fno-exceptions' ],
|
||||
'conditions': [
|
||||
['OS=="mac"', {
|
||||
'xcode_settings': {
|
||||
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
|
||||
}
|
||||
}]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
4814
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/browser_build/bson.js
generated
vendored
Normal file
4814
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/browser_build/bson.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/browser_build/package.json
generated
vendored
Normal file
8
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/browser_build/package.json
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{ "name" : "bson"
|
||||
, "description" : "A bson parser for node.js and the browser"
|
||||
, "main": "../lib/bson/bson"
|
||||
, "directories" : { "lib" : "../lib/bson" }
|
||||
, "engines" : { "node" : ">=0.6.0" }
|
||||
, "licenses" : [ { "type" : "Apache License, Version 2.0"
|
||||
, "url" : "http://www.apache.org/licenses/LICENSE-2.0" } ]
|
||||
}
|
||||
355
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/Makefile
generated
vendored
Normal file
355
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/Makefile
generated
vendored
Normal file
@@ -0,0 +1,355 @@
|
||||
# We borrow heavily from the kernel build setup, though we are simpler since
|
||||
# we don't have Kconfig tweaking settings on us.
|
||||
|
||||
# The implicit make rules have it looking for RCS files, among other things.
|
||||
# We instead explicitly write all the rules we care about.
|
||||
# It's even quicker (saves ~200ms) to pass -r on the command line.
|
||||
MAKEFLAGS=-r
|
||||
|
||||
# The source directory tree.
|
||||
srcdir := ..
|
||||
abs_srcdir := $(abspath $(srcdir))
|
||||
|
||||
# The name of the builddir.
|
||||
builddir_name ?= .
|
||||
|
||||
# The V=1 flag on command line makes us verbosely print command lines.
|
||||
ifdef V
|
||||
quiet=
|
||||
else
|
||||
quiet=quiet_
|
||||
endif
|
||||
|
||||
# Specify BUILDTYPE=Release on the command line for a release build.
|
||||
BUILDTYPE ?= Release
|
||||
|
||||
# Directory all our build output goes into.
|
||||
# Note that this must be two directories beneath src/ for unit tests to pass,
|
||||
# as they reach into the src/ directory for data with relative paths.
|
||||
builddir ?= $(builddir_name)/$(BUILDTYPE)
|
||||
abs_builddir := $(abspath $(builddir))
|
||||
depsdir := $(builddir)/.deps
|
||||
|
||||
# Object output directory.
|
||||
obj := $(builddir)/obj
|
||||
abs_obj := $(abspath $(obj))
|
||||
|
||||
# We build up a list of every single one of the targets so we can slurp in the
|
||||
# generated dependency rule Makefiles in one pass.
|
||||
all_deps :=
|
||||
|
||||
|
||||
|
||||
# C++ apps need to be linked with g++.
|
||||
#
|
||||
# Note: flock is used to seralize linking. Linking is a memory-intensive
|
||||
# process so running parallel links can often lead to thrashing. To disable
|
||||
# the serialization, override LINK via an envrionment variable as follows:
|
||||
#
|
||||
# export LINK=g++
|
||||
#
|
||||
# This will allow make to invoke N linker processes as specified in -jN.
|
||||
LINK ?= ./gyp-mac-tool flock $(builddir)/linker.lock $(CXX)
|
||||
|
||||
CC.target ?= $(CC)
|
||||
CFLAGS.target ?= $(CFLAGS)
|
||||
CXX.target ?= $(CXX)
|
||||
CXXFLAGS.target ?= $(CXXFLAGS)
|
||||
LINK.target ?= $(LINK)
|
||||
LDFLAGS.target ?= $(LDFLAGS)
|
||||
AR.target ?= $(AR)
|
||||
|
||||
# TODO(evan): move all cross-compilation logic to gyp-time so we don't need
|
||||
# to replicate this environment fallback in make as well.
|
||||
CC.host ?= gcc
|
||||
CFLAGS.host ?=
|
||||
CXX.host ?= g++
|
||||
CXXFLAGS.host ?=
|
||||
LINK.host ?= g++
|
||||
LDFLAGS.host ?=
|
||||
AR.host ?= ar
|
||||
|
||||
# Define a dir function that can handle spaces.
|
||||
# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
|
||||
# "leading spaces cannot appear in the text of the first argument as written.
|
||||
# These characters can be put into the argument value by variable substitution."
|
||||
empty :=
|
||||
space := $(empty) $(empty)
|
||||
|
||||
# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces
|
||||
replace_spaces = $(subst $(space),?,$1)
|
||||
unreplace_spaces = $(subst ?,$(space),$1)
|
||||
dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1)))
|
||||
|
||||
# Flags to make gcc output dependency info. Note that you need to be
|
||||
# careful here to use the flags that ccache and distcc can understand.
|
||||
# We write to a dep file on the side first and then rename at the end
|
||||
# so we can't end up with a broken dep file.
|
||||
depfile = $(depsdir)/$(call replace_spaces,$@).d
|
||||
DEPFLAGS = -MMD -MF $(depfile).raw
|
||||
|
||||
# We have to fixup the deps output in a few ways.
|
||||
# (1) the file output should mention the proper .o file.
|
||||
# ccache or distcc lose the path to the target, so we convert a rule of
|
||||
# the form:
|
||||
# foobar.o: DEP1 DEP2
|
||||
# into
|
||||
# path/to/foobar.o: DEP1 DEP2
|
||||
# (2) we want missing files not to cause us to fail to build.
|
||||
# We want to rewrite
|
||||
# foobar.o: DEP1 DEP2 \
|
||||
# DEP3
|
||||
# to
|
||||
# DEP1:
|
||||
# DEP2:
|
||||
# DEP3:
|
||||
# so if the files are missing, they're just considered phony rules.
|
||||
# We have to do some pretty insane escaping to get those backslashes
|
||||
# and dollar signs past make, the shell, and sed at the same time.
|
||||
# Doesn't work with spaces, but that's fine: .d files have spaces in
|
||||
# their names replaced with other characters.
|
||||
define fixup_dep
|
||||
# The depfile may not exist if the input file didn't have any #includes.
|
||||
touch $(depfile).raw
|
||||
# Fixup path as in (1).
|
||||
sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)
|
||||
# Add extra rules as in (2).
|
||||
# We remove slashes and replace spaces with new lines;
|
||||
# remove blank lines;
|
||||
# delete the first line and append a colon to the remaining lines.
|
||||
sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\
|
||||
grep -v '^$$' |\
|
||||
sed -e 1d -e 's|$$|:|' \
|
||||
>> $(depfile)
|
||||
rm $(depfile).raw
|
||||
endef
|
||||
|
||||
# Command definitions:
|
||||
# - cmd_foo is the actual command to run;
|
||||
# - quiet_cmd_foo is the brief-output summary of the command.
|
||||
|
||||
quiet_cmd_cc = CC($(TOOLSET)) $@
|
||||
cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $<
|
||||
|
||||
quiet_cmd_cxx = CXX($(TOOLSET)) $@
|
||||
cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
|
||||
|
||||
quiet_cmd_objc = CXX($(TOOLSET)) $@
|
||||
cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $<
|
||||
|
||||
quiet_cmd_objcxx = CXX($(TOOLSET)) $@
|
||||
cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $<
|
||||
|
||||
# Commands for precompiled header files.
|
||||
quiet_cmd_pch_c = CXX($(TOOLSET)) $@
|
||||
cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
|
||||
quiet_cmd_pch_cc = CXX($(TOOLSET)) $@
|
||||
cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
|
||||
quiet_cmd_pch_m = CXX($(TOOLSET)) $@
|
||||
cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $<
|
||||
quiet_cmd_pch_mm = CXX($(TOOLSET)) $@
|
||||
cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $<
|
||||
|
||||
# gyp-mac-tool is written next to the root Makefile by gyp.
|
||||
# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd
|
||||
# already.
|
||||
quiet_cmd_mac_tool = MACTOOL $(4) $<
|
||||
cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@"
|
||||
|
||||
quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@
|
||||
cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4)
|
||||
|
||||
quiet_cmd_infoplist = INFOPLIST $@
|
||||
cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@"
|
||||
|
||||
quiet_cmd_touch = TOUCH $@
|
||||
cmd_touch = touch $@
|
||||
|
||||
quiet_cmd_copy = COPY $@
|
||||
# send stderr to /dev/null to ignore messages when linking directories.
|
||||
cmd_copy = rm -rf "$@" && cp -af "$<" "$@"
|
||||
|
||||
quiet_cmd_alink = LIBTOOL-STATIC $@
|
||||
cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^)
|
||||
|
||||
quiet_cmd_link = LINK($(TOOLSET)) $@
|
||||
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)
|
||||
|
||||
# TODO(thakis): Find out and document the difference between shared_library and
|
||||
# loadable_module on mac.
|
||||
quiet_cmd_solink = SOLINK($(TOOLSET)) $@
|
||||
cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)
|
||||
|
||||
# TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass
|
||||
# -bundle -single_module here (for osmesa.so).
|
||||
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
|
||||
cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
|
||||
|
||||
|
||||
# Define an escape_quotes function to escape single quotes.
|
||||
# This allows us to handle quotes properly as long as we always use
|
||||
# use single quotes and escape_quotes.
|
||||
escape_quotes = $(subst ','\'',$(1))
|
||||
# This comment is here just to include a ' to unconfuse syntax highlighting.
|
||||
# Define an escape_vars function to escape '$' variable syntax.
|
||||
# This allows us to read/write command lines with shell variables (e.g.
|
||||
# $LD_LIBRARY_PATH), without triggering make substitution.
|
||||
escape_vars = $(subst $$,$$$$,$(1))
|
||||
# Helper that expands to a shell command to echo a string exactly as it is in
|
||||
# make. This uses printf instead of echo because printf's behaviour with respect
|
||||
# to escape sequences is more portable than echo's across different shells
|
||||
# (e.g., dash, bash).
|
||||
exact_echo = printf '%s\n' '$(call escape_quotes,$(1))'
|
||||
|
||||
# Helper to compare the command we're about to run against the command
|
||||
# we logged the last time we ran the command. Produces an empty
|
||||
# string (false) when the commands match.
|
||||
# Tricky point: Make has no string-equality test function.
|
||||
# The kernel uses the following, but it seems like it would have false
|
||||
# positives, where one string reordered its arguments.
|
||||
# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
|
||||
# $(filter-out $(cmd_$@), $(cmd_$(1))))
|
||||
# We instead substitute each for the empty string into the other, and
|
||||
# say they're equal if both substitutions produce the empty string.
|
||||
# .d files contain ? instead of spaces, take that into account.
|
||||
command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\
|
||||
$(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1))))
|
||||
|
||||
# Helper that is non-empty when a prerequisite changes.
|
||||
# Normally make does this implicitly, but we force rules to always run
|
||||
# so we can check their command lines.
|
||||
# $? -- new prerequisites
|
||||
# $| -- order-only dependencies
|
||||
prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?))
|
||||
|
||||
# Helper that executes all postbuilds, and deletes the output file when done
|
||||
# if any of the postbuilds failed.
|
||||
define do_postbuilds
|
||||
@E=0;\
|
||||
for p in $(POSTBUILDS); do\
|
||||
eval $$p;\
|
||||
F=$$?;\
|
||||
if [ $$F -ne 0 ]; then\
|
||||
E=$$F;\
|
||||
fi;\
|
||||
done;\
|
||||
if [ $$E -ne 0 ]; then\
|
||||
rm -rf "$@";\
|
||||
exit $$E;\
|
||||
fi
|
||||
endef
|
||||
|
||||
# do_cmd: run a command via the above cmd_foo names, if necessary.
|
||||
# Should always run for a given target to handle command-line changes.
|
||||
# Second argument, if non-zero, makes it do asm/C/C++ dependency munging.
|
||||
# Third argument, if non-zero, makes it do POSTBUILDS processing.
|
||||
# Note: We intentionally do NOT call dirx for depfile, since it contains ? for
|
||||
# spaces already and dirx strips the ? characters.
|
||||
define do_cmd
|
||||
$(if $(or $(command_changed),$(prereq_changed)),
|
||||
@$(call exact_echo, $($(quiet)cmd_$(1)))
|
||||
@mkdir -p "$(call dirx,$@)" "$(dir $(depfile))"
|
||||
$(if $(findstring flock,$(word 2,$(cmd_$1))),
|
||||
@$(cmd_$(1))
|
||||
@echo " $(quiet_cmd_$(1)): Finished",
|
||||
@$(cmd_$(1))
|
||||
)
|
||||
@$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile)
|
||||
@$(if $(2),$(fixup_dep))
|
||||
$(if $(and $(3), $(POSTBUILDS)),
|
||||
$(call do_postbuilds)
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# Declare the "all" target first so it is the default,
|
||||
# even though we don't have the deps yet.
|
||||
.PHONY: all
|
||||
all:
|
||||
|
||||
# make looks for ways to re-generate included makefiles, but in our case, we
|
||||
# don't have a direct way. Explicitly telling make that it has nothing to do
|
||||
# for them makes it go faster.
|
||||
%.d: ;
|
||||
|
||||
# Use FORCE_DO_CMD to force a target to run. Should be coupled with
|
||||
# do_cmd.
|
||||
.PHONY: FORCE_DO_CMD
|
||||
FORCE_DO_CMD:
|
||||
|
||||
TOOLSET := target
|
||||
# Suffix rules, putting all outputs into $(obj).
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.m FORCE_DO_CMD
|
||||
@$(call do_cmd,objc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.mm FORCE_DO_CMD
|
||||
@$(call do_cmd,objcxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
|
||||
# Try building from generated source, too.
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.m FORCE_DO_CMD
|
||||
@$(call do_cmd,objc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.mm FORCE_DO_CMD
|
||||
@$(call do_cmd,objcxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.m FORCE_DO_CMD
|
||||
@$(call do_cmd,objc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.mm FORCE_DO_CMD
|
||||
@$(call do_cmd,objcxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
|
||||
|
||||
ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
|
||||
$(findstring $(join ^,$(prefix)),\
|
||||
$(join ^,bson.target.mk)))),)
|
||||
include bson.target.mk
|
||||
endif
|
||||
|
||||
quiet_cmd_regen_makefile = ACTION Regenerating $@
|
||||
cmd_regen_makefile = /usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -I/Users/azat/Documents/Development/mongoui/node_modules/mongodb/node_modules/bson/build/config.gypi -I/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/Users/azat/.node-gyp/0.10.12/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/azat/.node-gyp/0.10.12" "-Dmodule_root_dir=/Users/azat/Documents/Development/mongoui/node_modules/mongodb/node_modules/bson" binding.gyp
|
||||
Makefile: $(srcdir)/../../../../../../../.node-gyp/0.10.12/common.gypi $(srcdir)/../../../../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp
|
||||
$(call do_cmd,regen_makefile)
|
||||
|
||||
# "all" is a concatenation of the "all" targets from all the included
|
||||
# sub-makefiles. This is just here to clarify.
|
||||
all:
|
||||
|
||||
# Add in dependency-tracking rules. $(all_deps) is the list of every single
|
||||
# target in our tree. Only consider the ones with .d (dependency) info:
|
||||
d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d))
|
||||
ifneq ($(d_files),)
|
||||
include $(d_files)
|
||||
endif
|
||||
1
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/Release/.deps/Release/bson.node.d
generated
vendored
Normal file
1
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/Release/.deps/Release/bson.node.d
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
cmd_Release/bson.node := ./gyp-mac-tool flock ./Release/linker.lock c++ -shared -Wl,-search_paths_first -mmacosx-version-min=10.5 -arch x86_64 -L./Release -install_name @rpath/bson.node -o Release/bson.node Release/obj.target/bson/ext/bson.o -undefined dynamic_lookup
|
||||
24
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/Release/.deps/Release/obj.target/bson/ext/bson.o.d
generated
vendored
Normal file
24
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/Release/.deps/Release/obj.target/bson/ext/bson.o.d
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
cmd_Release/obj.target/bson/ext/bson.o := c++ '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/Users/azat/.node-gyp/0.10.12/src -I/Users/azat/.node-gyp/0.10.12/deps/uv/include -I/Users/azat/.node-gyp/0.10.12/deps/v8/include -Os -gdwarf-2 -mmacosx-version-min=10.5 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-rtti -fno-threadsafe-statics -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/bson/ext/bson.o.d.raw -c -o Release/obj.target/bson/ext/bson.o ../ext/bson.cc
|
||||
Release/obj.target/bson/ext/bson.o: ../ext/bson.cc \
|
||||
/Users/azat/.node-gyp/0.10.12/deps/v8/include/v8.h \
|
||||
/Users/azat/.node-gyp/0.10.12/deps/v8/include/v8stdint.h \
|
||||
/Users/azat/.node-gyp/0.10.12/src/node.h \
|
||||
/Users/azat/.node-gyp/0.10.12/deps/uv/include/uv.h \
|
||||
/Users/azat/.node-gyp/0.10.12/deps/uv/include/uv-private/uv-unix.h \
|
||||
/Users/azat/.node-gyp/0.10.12/deps/uv/include/uv-private/ngx-queue.h \
|
||||
/Users/azat/.node-gyp/0.10.12/deps/uv/include/uv-private/uv-darwin.h \
|
||||
/Users/azat/.node-gyp/0.10.12/src/node_object_wrap.h \
|
||||
/Users/azat/.node-gyp/0.10.12/src/node_version.h \
|
||||
/Users/azat/.node-gyp/0.10.12/src/node_buffer.h ../ext/bson.h
|
||||
../ext/bson.cc:
|
||||
/Users/azat/.node-gyp/0.10.12/deps/v8/include/v8.h:
|
||||
/Users/azat/.node-gyp/0.10.12/deps/v8/include/v8stdint.h:
|
||||
/Users/azat/.node-gyp/0.10.12/src/node.h:
|
||||
/Users/azat/.node-gyp/0.10.12/deps/uv/include/uv.h:
|
||||
/Users/azat/.node-gyp/0.10.12/deps/uv/include/uv-private/uv-unix.h:
|
||||
/Users/azat/.node-gyp/0.10.12/deps/uv/include/uv-private/ngx-queue.h:
|
||||
/Users/azat/.node-gyp/0.10.12/deps/uv/include/uv-private/uv-darwin.h:
|
||||
/Users/azat/.node-gyp/0.10.12/src/node_object_wrap.h:
|
||||
/Users/azat/.node-gyp/0.10.12/src/node_version.h:
|
||||
/Users/azat/.node-gyp/0.10.12/src/node_buffer.h:
|
||||
../ext/bson.h:
|
||||
BIN
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/Release/bson.node
generated
vendored
Executable file
BIN
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/Release/bson.node
generated
vendored
Executable file
Binary file not shown.
0
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/Release/linker.lock
generated
vendored
Normal file
0
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/Release/linker.lock
generated
vendored
Normal file
BIN
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/Release/obj.target/bson/ext/bson.o
generated
vendored
Normal file
BIN
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/Release/obj.target/bson/ext/bson.o
generated
vendored
Normal file
Binary file not shown.
6
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/binding.Makefile
generated
vendored
Normal file
6
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/binding.Makefile
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# This file is generated by gyp; do not edit.
|
||||
|
||||
export builddir_name ?= build/./.
|
||||
.PHONY: all
|
||||
all:
|
||||
$(MAKE) bson
|
||||
154
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/bson.target.mk
generated
vendored
Normal file
154
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/bson.target.mk
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
# This file is generated by gyp; do not edit.
|
||||
|
||||
TOOLSET := target
|
||||
TARGET := bson
|
||||
DEFS_Debug := \
|
||||
'-D_DARWIN_USE_64_BIT_INODE=1' \
|
||||
'-D_LARGEFILE_SOURCE' \
|
||||
'-D_FILE_OFFSET_BITS=64' \
|
||||
'-DBUILDING_NODE_EXTENSION' \
|
||||
'-DDEBUG' \
|
||||
'-D_DEBUG'
|
||||
|
||||
# Flags passed to all source files.
|
||||
CFLAGS_Debug := \
|
||||
-O0 \
|
||||
-gdwarf-2 \
|
||||
-mmacosx-version-min=10.5 \
|
||||
-arch x86_64 \
|
||||
-Wall \
|
||||
-Wendif-labels \
|
||||
-W \
|
||||
-Wno-unused-parameter
|
||||
|
||||
# Flags passed to only C files.
|
||||
CFLAGS_C_Debug := \
|
||||
-fno-strict-aliasing
|
||||
|
||||
# Flags passed to only C++ files.
|
||||
CFLAGS_CC_Debug := \
|
||||
-fno-rtti \
|
||||
-fno-threadsafe-statics \
|
||||
-fno-strict-aliasing
|
||||
|
||||
# Flags passed to only ObjC files.
|
||||
CFLAGS_OBJC_Debug :=
|
||||
|
||||
# Flags passed to only ObjC++ files.
|
||||
CFLAGS_OBJCC_Debug :=
|
||||
|
||||
INCS_Debug := \
|
||||
-I/Users/azat/.node-gyp/0.10.12/src \
|
||||
-I/Users/azat/.node-gyp/0.10.12/deps/uv/include \
|
||||
-I/Users/azat/.node-gyp/0.10.12/deps/v8/include
|
||||
|
||||
DEFS_Release := \
|
||||
'-D_DARWIN_USE_64_BIT_INODE=1' \
|
||||
'-D_LARGEFILE_SOURCE' \
|
||||
'-D_FILE_OFFSET_BITS=64' \
|
||||
'-DBUILDING_NODE_EXTENSION'
|
||||
|
||||
# Flags passed to all source files.
|
||||
CFLAGS_Release := \
|
||||
-Os \
|
||||
-gdwarf-2 \
|
||||
-mmacosx-version-min=10.5 \
|
||||
-arch x86_64 \
|
||||
-Wall \
|
||||
-Wendif-labels \
|
||||
-W \
|
||||
-Wno-unused-parameter
|
||||
|
||||
# Flags passed to only C files.
|
||||
CFLAGS_C_Release := \
|
||||
-fno-strict-aliasing
|
||||
|
||||
# Flags passed to only C++ files.
|
||||
CFLAGS_CC_Release := \
|
||||
-fno-rtti \
|
||||
-fno-threadsafe-statics \
|
||||
-fno-strict-aliasing
|
||||
|
||||
# Flags passed to only ObjC files.
|
||||
CFLAGS_OBJC_Release :=
|
||||
|
||||
# Flags passed to only ObjC++ files.
|
||||
CFLAGS_OBJCC_Release :=
|
||||
|
||||
INCS_Release := \
|
||||
-I/Users/azat/.node-gyp/0.10.12/src \
|
||||
-I/Users/azat/.node-gyp/0.10.12/deps/uv/include \
|
||||
-I/Users/azat/.node-gyp/0.10.12/deps/v8/include
|
||||
|
||||
OBJS := \
|
||||
$(obj).target/$(TARGET)/ext/bson.o
|
||||
|
||||
# Add to the list of files we specially track dependencies for.
|
||||
all_deps += $(OBJS)
|
||||
|
||||
# CFLAGS et al overrides must be target-local.
|
||||
# See "Target-specific Variable Values" in the GNU Make manual.
|
||||
$(OBJS): TOOLSET := $(TOOLSET)
|
||||
$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
|
||||
$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
|
||||
$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))
|
||||
$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))
|
||||
|
||||
# Suffix rules, putting all outputs into $(obj).
|
||||
|
||||
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
|
||||
# Try building from generated source, too.
|
||||
|
||||
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
|
||||
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
|
||||
# End of this set of suffix rules
|
||||
### Rules for final target.
|
||||
LDFLAGS_Debug := \
|
||||
-Wl,-search_paths_first \
|
||||
-mmacosx-version-min=10.5 \
|
||||
-arch x86_64 \
|
||||
-L$(builddir) \
|
||||
-install_name @rpath/bson.node
|
||||
|
||||
LIBTOOLFLAGS_Debug := \
|
||||
-Wl,-search_paths_first
|
||||
|
||||
LDFLAGS_Release := \
|
||||
-Wl,-search_paths_first \
|
||||
-mmacosx-version-min=10.5 \
|
||||
-arch x86_64 \
|
||||
-L$(builddir) \
|
||||
-install_name @rpath/bson.node
|
||||
|
||||
LIBTOOLFLAGS_Release := \
|
||||
-Wl,-search_paths_first
|
||||
|
||||
LIBS := \
|
||||
-undefined dynamic_lookup
|
||||
|
||||
$(builddir)/bson.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
|
||||
$(builddir)/bson.node: LIBS := $(LIBS)
|
||||
$(builddir)/bson.node: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))
|
||||
$(builddir)/bson.node: TOOLSET := $(TOOLSET)
|
||||
$(builddir)/bson.node: $(OBJS) FORCE_DO_CMD
|
||||
$(call do_cmd,solink_module)
|
||||
|
||||
all_deps += $(builddir)/bson.node
|
||||
# Add target alias
|
||||
.PHONY: bson
|
||||
bson: $(builddir)/bson.node
|
||||
|
||||
# Short alias for building this executable.
|
||||
.PHONY: bson.node
|
||||
bson.node: $(builddir)/bson.node
|
||||
|
||||
# Add executable to "all" target.
|
||||
.PHONY: all
|
||||
all: $(builddir)/bson.node
|
||||
|
||||
114
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/config.gypi
generated
vendored
Normal file
114
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/config.gypi
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
# Do not edit. File was generated by node-gyp's "configure" step
|
||||
{
|
||||
"target_defaults": {
|
||||
"cflags": [],
|
||||
"default_configuration": "Release",
|
||||
"defines": [],
|
||||
"include_dirs": [],
|
||||
"libraries": []
|
||||
},
|
||||
"variables": {
|
||||
"clang": 0,
|
||||
"gcc_version": 42,
|
||||
"host_arch": "x64",
|
||||
"node_install_npm": "true",
|
||||
"node_prefix": "",
|
||||
"node_shared_cares": "false",
|
||||
"node_shared_http_parser": "false",
|
||||
"node_shared_libuv": "false",
|
||||
"node_shared_openssl": "false",
|
||||
"node_shared_v8": "false",
|
||||
"node_shared_zlib": "false",
|
||||
"node_tag": "",
|
||||
"node_unsafe_optimizations": 0,
|
||||
"node_use_dtrace": "true",
|
||||
"node_use_etw": "false",
|
||||
"node_use_openssl": "true",
|
||||
"node_use_perfctr": "false",
|
||||
"python": "/usr/bin/python",
|
||||
"target_arch": "x64",
|
||||
"v8_enable_gdbjit": 0,
|
||||
"v8_no_strict_aliasing": 1,
|
||||
"v8_use_snapshot": "false",
|
||||
"nodedir": "/Users/azat/.node-gyp/0.10.12",
|
||||
"copy_dev_lib": "true",
|
||||
"standalone_static_library": 1,
|
||||
"save_dev": "",
|
||||
"browser": "",
|
||||
"viewer": "man",
|
||||
"rollback": "true",
|
||||
"usage": "",
|
||||
"globalignorefile": "/usr/local/etc/npmignore",
|
||||
"init_author_url": "",
|
||||
"shell": "/bin/zsh",
|
||||
"parseable": "",
|
||||
"shrinkwrap": "true",
|
||||
"email": "hi@azat.co",
|
||||
"userignorefile": "/Users/azat/.npmignore",
|
||||
"cache_max": "null",
|
||||
"init_author_email": "",
|
||||
"sign_git_tag": "",
|
||||
"ignore": "",
|
||||
"long": "",
|
||||
"registry": "https://registry.npmjs.org/",
|
||||
"fetch_retries": "2",
|
||||
"npat": "",
|
||||
"message": "%s",
|
||||
"versions": "",
|
||||
"globalconfig": "/usr/local/etc/npmrc",
|
||||
"always_auth": "",
|
||||
"cache_lock_retries": "10",
|
||||
"fetch_retry_mintimeout": "10000",
|
||||
"proprietary_attribs": "true",
|
||||
"coverage": "",
|
||||
"json": "",
|
||||
"pre": "",
|
||||
"description": "true",
|
||||
"engine_strict": "",
|
||||
"https_proxy": "",
|
||||
"init_module": "/Users/azat/.npm-init.js",
|
||||
"userconfig": "/Users/azat/.npmrc",
|
||||
"npaturl": "http://npat.npmjs.org/",
|
||||
"node_version": "v0.10.12",
|
||||
"user": "",
|
||||
"editor": "vi",
|
||||
"save": "",
|
||||
"tag": "latest",
|
||||
"global": "",
|
||||
"username": "azat",
|
||||
"optional": "true",
|
||||
"bin_links": "true",
|
||||
"force": "",
|
||||
"searchopts": "",
|
||||
"depth": "null",
|
||||
"rebuild_bundle": "true",
|
||||
"searchsort": "name",
|
||||
"unicode": "true",
|
||||
"yes": "",
|
||||
"fetch_retry_maxtimeout": "60000",
|
||||
"strict_ssl": "true",
|
||||
"dev": "",
|
||||
"fetch_retry_factor": "10",
|
||||
"group": "20",
|
||||
"cache_lock_stale": "60000",
|
||||
"version": "",
|
||||
"cache_min": "10",
|
||||
"cache": "/Users/azat/.npm",
|
||||
"searchexclude": "",
|
||||
"color": "true",
|
||||
"save_optional": "",
|
||||
"user_agent": "node/v0.10.12 darwin x64",
|
||||
"cache_lock_wait": "10000",
|
||||
"production": "",
|
||||
"save_bundle": "",
|
||||
"init_version": "0.0.0",
|
||||
"umask": "18",
|
||||
"git": "git",
|
||||
"init_author_name": "",
|
||||
"onload_script": "",
|
||||
"tmp": "/var/folders/q5/0zn95nld30b7fnhz5yywb52m0000gn/T/",
|
||||
"unsafe_perm": "true",
|
||||
"link": "",
|
||||
"prefix": "/usr/local"
|
||||
}
|
||||
}
|
||||
211
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/gyp-mac-tool
generated
vendored
Executable file
211
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build/gyp-mac-tool
generated
vendored
Executable file
@@ -0,0 +1,211 @@
|
||||
#!/usr/bin/env python
|
||||
# Generated by gyp. Do not edit.
|
||||
# Copyright (c) 2012 Google Inc. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
"""Utility functions to perform Xcode-style build steps.
|
||||
|
||||
These functions are executed via gyp-mac-tool when using the Makefile generator.
|
||||
"""
|
||||
|
||||
import fcntl
|
||||
import os
|
||||
import plistlib
|
||||
import re
|
||||
import shutil
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def main(args):
|
||||
executor = MacTool()
|
||||
exit_code = executor.Dispatch(args)
|
||||
if exit_code is not None:
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
class MacTool(object):
|
||||
"""This class performs all the Mac tooling steps. The methods can either be
|
||||
executed directly, or dispatched from an argument list."""
|
||||
|
||||
def Dispatch(self, args):
|
||||
"""Dispatches a string command to a method."""
|
||||
if len(args) < 1:
|
||||
raise Exception("Not enough arguments")
|
||||
|
||||
method = "Exec%s" % self._CommandifyName(args[0])
|
||||
return getattr(self, method)(*args[1:])
|
||||
|
||||
def _CommandifyName(self, name_string):
|
||||
"""Transforms a tool name like copy-info-plist to CopyInfoPlist"""
|
||||
return name_string.title().replace('-', '')
|
||||
|
||||
def ExecCopyBundleResource(self, source, dest):
|
||||
"""Copies a resource file to the bundle/Resources directory, performing any
|
||||
necessary compilation on each resource."""
|
||||
extension = os.path.splitext(source)[1].lower()
|
||||
if os.path.isdir(source):
|
||||
# Copy tree.
|
||||
if os.path.exists(dest):
|
||||
shutil.rmtree(dest)
|
||||
shutil.copytree(source, dest)
|
||||
elif extension == '.xib':
|
||||
return self._CopyXIBFile(source, dest)
|
||||
elif extension == '.strings':
|
||||
self._CopyStringsFile(source, dest)
|
||||
else:
|
||||
shutil.copyfile(source, dest)
|
||||
|
||||
def _CopyXIBFile(self, source, dest):
|
||||
"""Compiles a XIB file with ibtool into a binary plist in the bundle."""
|
||||
tools_dir = os.environ.get('DEVELOPER_BIN_DIR', '/usr/bin')
|
||||
args = [os.path.join(tools_dir, 'ibtool'), '--errors', '--warnings',
|
||||
'--notices', '--output-format', 'human-readable-text', '--compile',
|
||||
dest, source]
|
||||
ibtool_section_re = re.compile(r'/\*.*\*/')
|
||||
ibtool_re = re.compile(r'.*note:.*is clipping its content')
|
||||
ibtoolout = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
current_section_header = None
|
||||
for line in ibtoolout.stdout:
|
||||
if ibtool_section_re.match(line):
|
||||
current_section_header = line
|
||||
elif not ibtool_re.match(line):
|
||||
if current_section_header:
|
||||
sys.stdout.write(current_section_header)
|
||||
current_section_header = None
|
||||
sys.stdout.write(line)
|
||||
return ibtoolout.returncode
|
||||
|
||||
def _CopyStringsFile(self, source, dest):
|
||||
"""Copies a .strings file using iconv to reconvert the input into UTF-16."""
|
||||
input_code = self._DetectInputEncoding(source) or "UTF-8"
|
||||
fp = open(dest, 'w')
|
||||
args = ['/usr/bin/iconv', '--from-code', input_code, '--to-code',
|
||||
'UTF-16', source]
|
||||
subprocess.call(args, stdout=fp)
|
||||
fp.close()
|
||||
|
||||
def _DetectInputEncoding(self, file_name):
|
||||
"""Reads the first few bytes from file_name and tries to guess the text
|
||||
encoding. Returns None as a guess if it can't detect it."""
|
||||
fp = open(file_name, 'rb')
|
||||
try:
|
||||
header = fp.read(3)
|
||||
except e:
|
||||
fp.close()
|
||||
return None
|
||||
fp.close()
|
||||
if header.startswith("\xFE\xFF"):
|
||||
return "UTF-16BE"
|
||||
elif header.startswith("\xFF\xFE"):
|
||||
return "UTF-16LE"
|
||||
elif header.startswith("\xEF\xBB\xBF"):
|
||||
return "UTF-8"
|
||||
else:
|
||||
return None
|
||||
|
||||
def ExecCopyInfoPlist(self, source, dest):
|
||||
"""Copies the |source| Info.plist to the destination directory |dest|."""
|
||||
# Read the source Info.plist into memory.
|
||||
fd = open(source, 'r')
|
||||
lines = fd.read()
|
||||
fd.close()
|
||||
|
||||
# Go through all the environment variables and replace them as variables in
|
||||
# the file.
|
||||
for key in os.environ:
|
||||
if key.startswith('_'):
|
||||
continue
|
||||
evar = '${%s}' % key
|
||||
lines = string.replace(lines, evar, os.environ[key])
|
||||
|
||||
# Write out the file with variables replaced.
|
||||
fd = open(dest, 'w')
|
||||
fd.write(lines)
|
||||
fd.close()
|
||||
|
||||
# Now write out PkgInfo file now that the Info.plist file has been
|
||||
# "compiled".
|
||||
self._WritePkgInfo(dest)
|
||||
|
||||
def _WritePkgInfo(self, info_plist):
|
||||
"""This writes the PkgInfo file from the data stored in Info.plist."""
|
||||
plist = plistlib.readPlist(info_plist)
|
||||
if not plist:
|
||||
return
|
||||
|
||||
# Only create PkgInfo for executable types.
|
||||
package_type = plist['CFBundlePackageType']
|
||||
if package_type != 'APPL':
|
||||
return
|
||||
|
||||
# The format of PkgInfo is eight characters, representing the bundle type
|
||||
# and bundle signature, each four characters. If that is missing, four
|
||||
# '?' characters are used instead.
|
||||
signature_code = plist.get('CFBundleSignature', '????')
|
||||
if len(signature_code) != 4: # Wrong length resets everything, too.
|
||||
signature_code = '?' * 4
|
||||
|
||||
dest = os.path.join(os.path.dirname(info_plist), 'PkgInfo')
|
||||
fp = open(dest, 'w')
|
||||
fp.write('%s%s' % (package_type, signature_code))
|
||||
fp.close()
|
||||
|
||||
def ExecFlock(self, lockfile, *cmd_list):
|
||||
"""Emulates the most basic behavior of Linux's flock(1)."""
|
||||
# Rely on exception handling to report errors.
|
||||
fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666)
|
||||
fcntl.flock(fd, fcntl.LOCK_EX)
|
||||
return subprocess.call(cmd_list)
|
||||
|
||||
def ExecFilterLibtool(self, *cmd_list):
|
||||
"""Calls libtool and filters out 'libtool: file: foo.o has no symbols'."""
|
||||
libtool_re = re.compile(r'^libtool: file: .* has no symbols$')
|
||||
libtoolout = subprocess.Popen(cmd_list, stderr=subprocess.PIPE)
|
||||
_, err = libtoolout.communicate()
|
||||
for line in err.splitlines():
|
||||
if not libtool_re.match(line):
|
||||
print >>sys.stderr, line
|
||||
return libtoolout.returncode
|
||||
|
||||
def ExecPackageFramework(self, framework, version):
|
||||
"""Takes a path to Something.framework and the Current version of that and
|
||||
sets up all the symlinks."""
|
||||
# Find the name of the binary based on the part before the ".framework".
|
||||
binary = os.path.basename(framework).split('.')[0]
|
||||
|
||||
CURRENT = 'Current'
|
||||
RESOURCES = 'Resources'
|
||||
VERSIONS = 'Versions'
|
||||
|
||||
if not os.path.exists(os.path.join(framework, VERSIONS, version, binary)):
|
||||
# Binary-less frameworks don't seem to contain symlinks (see e.g.
|
||||
# chromium's out/Debug/org.chromium.Chromium.manifest/ bundle).
|
||||
return
|
||||
|
||||
# Move into the framework directory to set the symlinks correctly.
|
||||
pwd = os.getcwd()
|
||||
os.chdir(framework)
|
||||
|
||||
# Set up the Current version.
|
||||
self._Relink(version, os.path.join(VERSIONS, CURRENT))
|
||||
|
||||
# Set up the root symlinks.
|
||||
self._Relink(os.path.join(VERSIONS, CURRENT, binary), binary)
|
||||
self._Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES)
|
||||
|
||||
# Back to where we were before!
|
||||
os.chdir(pwd)
|
||||
|
||||
def _Relink(self, dest, link):
|
||||
"""Creates a symlink to |dest| named |link|. If |link| already exists,
|
||||
it is overwritten."""
|
||||
if os.path.lexists(link):
|
||||
os.remove(link)
|
||||
os.symlink(dest, link)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
7
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build_browser.js
generated
vendored
Normal file
7
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/build_browser.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
require('one');
|
||||
|
||||
one('./package.json')
|
||||
.tie('bson', BSON)
|
||||
// .exclude('buffer')
|
||||
.tie('buffer', {})
|
||||
.save('./browser_build/bson.js')
|
||||
0
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/builderror.log
generated
vendored
Normal file
0
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/builderror.log
generated
vendored
Normal file
28
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/Makefile
generated
vendored
Normal file
28
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/Makefile
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
NODE = node
|
||||
name = all
|
||||
JOBS = 1
|
||||
|
||||
all:
|
||||
rm -rf build .lock-wscript bson.node
|
||||
node-waf configure build
|
||||
cp -R ./build/Release/bson.node . || true
|
||||
|
||||
all_debug:
|
||||
rm -rf build .lock-wscript bson.node
|
||||
node-waf --debug configure build
|
||||
cp -R ./build/Release/bson.node . || true
|
||||
|
||||
clang:
|
||||
rm -rf build .lock-wscript bson.node
|
||||
CXX=clang node-waf configure build
|
||||
cp -R ./build/Release/bson.node . || true
|
||||
|
||||
clang_debug:
|
||||
rm -rf build .lock-wscript bson.node
|
||||
CXX=clang node-waf --debug configure build
|
||||
cp -R ./build/Release/bson.node . || true
|
||||
|
||||
clean:
|
||||
rm -rf build .lock-wscript bson.node
|
||||
|
||||
.PHONY: all
|
||||
1006
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/bson.cc
generated
vendored
Normal file
1006
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/bson.cc
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
273
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/bson.h
generated
vendored
Normal file
273
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/bson.h
generated
vendored
Normal file
@@ -0,0 +1,273 @@
|
||||
//===========================================================================
|
||||
|
||||
#ifndef BSON_H_
|
||||
#define BSON_H_
|
||||
|
||||
//===========================================================================
|
||||
|
||||
#define USE_MISALIGNED_MEMORY_ACCESS 1
|
||||
|
||||
#include <node.h>
|
||||
#include <node_object_wrap.h>
|
||||
#include <v8.h>
|
||||
|
||||
using namespace v8;
|
||||
using namespace node;
|
||||
|
||||
//===========================================================================
|
||||
|
||||
enum BsonType
|
||||
{
|
||||
BSON_TYPE_NUMBER = 1,
|
||||
BSON_TYPE_STRING = 2,
|
||||
BSON_TYPE_OBJECT = 3,
|
||||
BSON_TYPE_ARRAY = 4,
|
||||
BSON_TYPE_BINARY = 5,
|
||||
BSON_TYPE_UNDEFINED = 6,
|
||||
BSON_TYPE_OID = 7,
|
||||
BSON_TYPE_BOOLEAN = 8,
|
||||
BSON_TYPE_DATE = 9,
|
||||
BSON_TYPE_NULL = 10,
|
||||
BSON_TYPE_REGEXP = 11,
|
||||
BSON_TYPE_CODE = 13,
|
||||
BSON_TYPE_SYMBOL = 14,
|
||||
BSON_TYPE_CODE_W_SCOPE = 15,
|
||||
BSON_TYPE_INT = 16,
|
||||
BSON_TYPE_TIMESTAMP = 17,
|
||||
BSON_TYPE_LONG = 18,
|
||||
BSON_TYPE_MAX_KEY = 0x7f,
|
||||
BSON_TYPE_MIN_KEY = 0xff
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
|
||||
template<typename T> class BSONSerializer;
|
||||
|
||||
class BSON : public ObjectWrap {
|
||||
public:
|
||||
BSON();
|
||||
~BSON() {}
|
||||
|
||||
static void Initialize(Handle<Object> target);
|
||||
static Handle<Value> BSONDeserializeStream(const Arguments &args);
|
||||
|
||||
// JS based objects
|
||||
static Handle<Value> BSONSerialize(const Arguments &args);
|
||||
static Handle<Value> BSONDeserialize(const Arguments &args);
|
||||
|
||||
// Calculate size of function
|
||||
static Handle<Value> CalculateObjectSize(const Arguments &args);
|
||||
static Handle<Value> SerializeWithBufferAndIndex(const Arguments &args);
|
||||
|
||||
// Constructor used for creating new BSON objects from C++
|
||||
static Persistent<FunctionTemplate> constructor_template;
|
||||
|
||||
private:
|
||||
static Handle<Value> New(const Arguments &args);
|
||||
static Handle<Value> deserialize(BSON *bson, char *data, uint32_t dataLength, uint32_t startIndex, bool is_array_item);
|
||||
|
||||
// BSON type instantiate functions
|
||||
Persistent<Function> longConstructor;
|
||||
Persistent<Function> objectIDConstructor;
|
||||
Persistent<Function> binaryConstructor;
|
||||
Persistent<Function> codeConstructor;
|
||||
Persistent<Function> dbrefConstructor;
|
||||
Persistent<Function> symbolConstructor;
|
||||
Persistent<Function> doubleConstructor;
|
||||
Persistent<Function> timestampConstructor;
|
||||
Persistent<Function> minKeyConstructor;
|
||||
Persistent<Function> maxKeyConstructor;
|
||||
|
||||
// Equality Objects
|
||||
Persistent<String> longString;
|
||||
Persistent<String> objectIDString;
|
||||
Persistent<String> binaryString;
|
||||
Persistent<String> codeString;
|
||||
Persistent<String> dbrefString;
|
||||
Persistent<String> symbolString;
|
||||
Persistent<String> doubleString;
|
||||
Persistent<String> timestampString;
|
||||
Persistent<String> minKeyString;
|
||||
Persistent<String> maxKeyString;
|
||||
|
||||
// Equality speed up comparison objects
|
||||
Persistent<String> _bsontypeString;
|
||||
Persistent<String> _longLowString;
|
||||
Persistent<String> _longHighString;
|
||||
Persistent<String> _objectIDidString;
|
||||
Persistent<String> _binaryPositionString;
|
||||
Persistent<String> _binarySubTypeString;
|
||||
Persistent<String> _binaryBufferString;
|
||||
Persistent<String> _doubleValueString;
|
||||
Persistent<String> _symbolValueString;
|
||||
|
||||
Persistent<String> _dbRefRefString;
|
||||
Persistent<String> _dbRefIdRefString;
|
||||
Persistent<String> _dbRefDbRefString;
|
||||
Persistent<String> _dbRefNamespaceString;
|
||||
Persistent<String> _dbRefDbString;
|
||||
Persistent<String> _dbRefOidString;
|
||||
|
||||
Persistent<String> _codeCodeString;
|
||||
Persistent<String> _codeScopeString;
|
||||
Persistent<String> _toBSONString;
|
||||
|
||||
Local<Object> GetSerializeObject(const Handle<Value>& object);
|
||||
|
||||
template<typename T> friend class BSONSerializer;
|
||||
friend class BSONDeserializer;
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
|
||||
class CountStream
|
||||
{
|
||||
public:
|
||||
CountStream() : count(0) { }
|
||||
|
||||
void WriteByte(int value) { ++count; }
|
||||
void WriteByte(const Handle<Object>&, const Handle<String>&) { ++count; }
|
||||
void WriteBool(const Handle<Value>& value) { ++count; }
|
||||
void WriteInt32(int32_t value) { count += 4; }
|
||||
void WriteInt32(const Handle<Value>& value) { count += 4; }
|
||||
void WriteInt32(const Handle<Object>& object, const Handle<String>& key) { count += 4; }
|
||||
void WriteInt64(int64_t value) { count += 8; }
|
||||
void WriteInt64(const Handle<Value>& value) { count += 8; }
|
||||
void WriteDouble(double value) { count += 8; }
|
||||
void WriteDouble(const Handle<Value>& value) { count += 8; }
|
||||
void WriteDouble(const Handle<Object>&, const Handle<String>&) { count += 8; }
|
||||
void WriteUInt32String(uint32_t name) { char buffer[32]; count += sprintf(buffer, "%u", name) + 1; }
|
||||
void WriteLengthPrefixedString(const Local<String>& value) { count += value->Utf8Length()+5; }
|
||||
void WriteObjectId(const Handle<Object>& object, const Handle<String>& key) { count += 12; }
|
||||
void WriteString(const Local<String>& value) { count += value->Utf8Length() + 1; } // This returns the number of bytes exclusive of the NULL terminator
|
||||
void WriteData(const char* data, size_t length) { count += length; }
|
||||
|
||||
void* BeginWriteType() { ++count; return NULL; }
|
||||
void CommitType(void*, BsonType) { }
|
||||
void* BeginWriteSize() { count += 4; return NULL; }
|
||||
void CommitSize(void*) { }
|
||||
|
||||
size_t GetSerializeSize() const { return count; }
|
||||
|
||||
// Do nothing. CheckKey is implemented for DataStream
|
||||
void CheckKey(const Local<String>&) { }
|
||||
|
||||
private:
|
||||
size_t count;
|
||||
};
|
||||
|
||||
class DataStream
|
||||
{
|
||||
public:
|
||||
DataStream(char* aDestinationBuffer) : destinationBuffer(aDestinationBuffer), p(aDestinationBuffer) { }
|
||||
|
||||
void WriteByte(int value) { *p++ = value; }
|
||||
void WriteByte(const Handle<Object>& object, const Handle<String>& key) { *p++ = object->Get(key)->Int32Value(); }
|
||||
#if USE_MISALIGNED_MEMORY_ACCESS
|
||||
void WriteInt32(int32_t value) { *reinterpret_cast<int32_t*>(p) = value; p += 4; }
|
||||
void WriteInt64(int64_t value) { *reinterpret_cast<int64_t*>(p) = value; p += 8; }
|
||||
void WriteDouble(double value) { *reinterpret_cast<double*>(p) = value; p += 8; }
|
||||
#else
|
||||
void WriteInt32(int32_t value) { memcpy(p, &value, 4); p += 4; }
|
||||
void WriteInt64(int64_t value) { memcpy(p, &value, 8); p += 8; }
|
||||
void WriteDouble(double value) { memcpy(p, &value, 8); p += 8; }
|
||||
#endif
|
||||
void WriteBool(const Handle<Value>& value) { WriteByte(value->BooleanValue() ? 1 : 0); }
|
||||
void WriteInt32(const Handle<Value>& value) { WriteInt32(value->Int32Value()); }
|
||||
void WriteInt32(const Handle<Object>& object, const Handle<String>& key) { WriteInt32(object->Get(key)); }
|
||||
void WriteInt64(const Handle<Value>& value) { WriteInt64(value->IntegerValue()); }
|
||||
void WriteDouble(const Handle<Value>& value) { WriteDouble(value->NumberValue()); }
|
||||
void WriteDouble(const Handle<Object>& object, const Handle<String>& key) { WriteDouble(object->Get(key)); }
|
||||
void WriteUInt32String(uint32_t name) { p += sprintf(p, "%u", name) + 1; }
|
||||
void WriteLengthPrefixedString(const Local<String>& value) { WriteInt32(value->Utf8Length()+1); WriteString(value); }
|
||||
void WriteObjectId(const Handle<Object>& object, const Handle<String>& key);
|
||||
void WriteString(const Local<String>& value) { p += value->WriteUtf8(p); } // This returns the number of bytes inclusive of the NULL terminator.
|
||||
void WriteData(const char* data, size_t length) { memcpy(p, data, length); p += length; }
|
||||
|
||||
void* BeginWriteType() { void* returnValue = p; p++; return returnValue; }
|
||||
void CommitType(void* beginPoint, BsonType value) { *reinterpret_cast<unsigned char*>(beginPoint) = value; }
|
||||
void* BeginWriteSize() { void* returnValue = p; p += 4; return returnValue; }
|
||||
|
||||
#if USE_MISALIGNED_MEMORY_ACCESS
|
||||
void CommitSize(void* beginPoint) { *reinterpret_cast<int32_t*>(beginPoint) = (int32_t) (p - (char*) beginPoint); }
|
||||
#else
|
||||
void CommitSize(void* beginPoint) { int32_t value = (int32_t) (p - (char*) beginPoint); memcpy(beginPoint, &value, 4); }
|
||||
#endif
|
||||
|
||||
size_t GetSerializeSize() const { return p - destinationBuffer; }
|
||||
|
||||
void CheckKey(const Local<String>& keyName);
|
||||
|
||||
protected:
|
||||
char *const destinationBuffer; // base, never changes
|
||||
char* p; // cursor into buffer
|
||||
};
|
||||
|
||||
template<typename T> class BSONSerializer : public T
|
||||
{
|
||||
private:
|
||||
typedef T Inherited;
|
||||
|
||||
public:
|
||||
BSONSerializer(BSON* aBson, bool aCheckKeys, bool aSerializeFunctions) : Inherited(), checkKeys(aCheckKeys), serializeFunctions(aSerializeFunctions), bson(aBson) { }
|
||||
BSONSerializer(BSON* aBson, bool aCheckKeys, bool aSerializeFunctions, char* parentParam) : Inherited(parentParam), checkKeys(aCheckKeys), serializeFunctions(aSerializeFunctions), bson(aBson) { }
|
||||
|
||||
void SerializeDocument(const Handle<Value>& value);
|
||||
void SerializeArray(const Handle<Value>& value);
|
||||
void SerializeValue(void* typeLocation, const Handle<Value>& value);
|
||||
|
||||
private:
|
||||
bool checkKeys;
|
||||
bool serializeFunctions;
|
||||
BSON* bson;
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
|
||||
class BSONDeserializer
|
||||
{
|
||||
public:
|
||||
BSONDeserializer(BSON* aBson, char* data, size_t length);
|
||||
BSONDeserializer(BSONDeserializer& parentSerializer, size_t length);
|
||||
|
||||
Handle<Value> DeserializeDocument();
|
||||
|
||||
bool HasMoreData() const { return p < pEnd; }
|
||||
Local<String> ReadCString();
|
||||
uint32_t ReadIntegerString();
|
||||
int32_t ReadRegexOptions();
|
||||
Local<String> ReadString();
|
||||
Local<String> ReadObjectId();
|
||||
|
||||
unsigned char ReadByte() { return *reinterpret_cast<unsigned char*>(p++); }
|
||||
#if USE_MISALIGNED_MEMORY_ACCESS
|
||||
int32_t ReadInt32() { int32_t returnValue = *reinterpret_cast<int32_t*>(p); p += 4; return returnValue; }
|
||||
uint32_t ReadUInt32() { uint32_t returnValue = *reinterpret_cast<uint32_t*>(p); p += 4; return returnValue; }
|
||||
int64_t ReadInt64() { int64_t returnValue = *reinterpret_cast<int64_t*>(p); p += 8; return returnValue; }
|
||||
double ReadDouble() { double returnValue = *reinterpret_cast<double*>(p); p += 8; return returnValue; }
|
||||
#else
|
||||
int32_t ReadInt32() { int32_t returnValue; memcpy(&returnValue, p, 4); p += 4; return returnValue; }
|
||||
uint32_t ReadUInt32() { uint32_t returnValue; memcpy(&returnValue, p, 4); p += 4; return returnValue; }
|
||||
int64_t ReadInt64() { int64_t returnValue; memcpy(&returnValue, p, 8); p += 8; return returnValue; }
|
||||
double ReadDouble() { double returnValue; memcpy(&returnValue, p, 8); p += 8; return returnValue; }
|
||||
#endif
|
||||
|
||||
size_t GetSerializeSize() const { return p - pStart; }
|
||||
|
||||
private:
|
||||
Handle<Value> DeserializeArray();
|
||||
Handle<Value> DeserializeValue(BsonType type);
|
||||
Handle<Value> DeserializeDocumentInternal();
|
||||
Handle<Value> DeserializeArrayInternal();
|
||||
|
||||
BSON* bson;
|
||||
char* const pStart;
|
||||
char* p;
|
||||
char* const pEnd;
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
|
||||
#endif // BSON_H_
|
||||
|
||||
//===========================================================================
|
||||
30
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/index.js
generated
vendored
Normal file
30
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/index.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
var bson = null;
|
||||
|
||||
// Load the precompiled win32 binary
|
||||
if(process.platform == "win32" && process.arch == "x64") {
|
||||
bson = require('./win32/x64/bson');
|
||||
} else if(process.platform == "win32" && process.arch == "ia32") {
|
||||
bson = require('./win32/ia32/bson');
|
||||
} else {
|
||||
bson = require('../build/Release/bson');
|
||||
}
|
||||
|
||||
exports.BSON = bson.BSON;
|
||||
exports.Long = require('../lib/bson/long').Long;
|
||||
exports.ObjectID = require('../lib/bson/objectid').ObjectID;
|
||||
exports.DBRef = require('../lib/bson/db_ref').DBRef;
|
||||
exports.Code = require('../lib/bson/code').Code;
|
||||
exports.Timestamp = require('../lib/bson/timestamp').Timestamp;
|
||||
exports.Binary = require('../lib/bson/binary').Binary;
|
||||
exports.Double = require('../lib/bson/double').Double;
|
||||
exports.MaxKey = require('../lib/bson/max_key').MaxKey;
|
||||
exports.MinKey = require('../lib/bson/min_key').MinKey;
|
||||
exports.Symbol = require('../lib/bson/symbol').Symbol;
|
||||
|
||||
// Just add constants tot he Native BSON parser
|
||||
exports.BSON.BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
||||
exports.BSON.BSON_BINARY_SUBTYPE_FUNCTION = 1;
|
||||
exports.BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
|
||||
exports.BSON.BSON_BINARY_SUBTYPE_UUID = 3;
|
||||
exports.BSON.BSON_BINARY_SUBTYPE_MD5 = 4;
|
||||
exports.BSON.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
|
||||
BIN
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/win32/ia32/bson.node
generated
vendored
Normal file
BIN
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/win32/ia32/bson.node
generated
vendored
Normal file
Binary file not shown.
BIN
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/win32/x64/bson.node
generated
vendored
Normal file
BIN
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/win32/x64/bson.node
generated
vendored
Normal file
Binary file not shown.
39
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/wscript
generated
vendored
Normal file
39
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/ext/wscript
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import Options
|
||||
from os import unlink, symlink, popen
|
||||
from os.path import exists
|
||||
|
||||
srcdir = "."
|
||||
blddir = "build"
|
||||
VERSION = "0.1.0"
|
||||
|
||||
def set_options(opt):
|
||||
opt.tool_options("compiler_cxx")
|
||||
opt.add_option( '--debug'
|
||||
, action='store_true'
|
||||
, default=False
|
||||
, help='Build debug variant [Default: False]'
|
||||
, dest='debug'
|
||||
)
|
||||
|
||||
def configure(conf):
|
||||
conf.check_tool("compiler_cxx")
|
||||
conf.check_tool("node_addon")
|
||||
conf.env.append_value('CXXFLAGS', ['-O3', '-funroll-loops'])
|
||||
|
||||
# conf.env.append_value('CXXFLAGS', ['-DDEBUG', '-g', '-O0', '-Wall', '-Wextra'])
|
||||
# conf.check(lib='node', libpath=['/usr/lib', '/usr/local/lib'], uselib_store='NODE')
|
||||
|
||||
def build(bld):
|
||||
obj = bld.new_task_gen("cxx", "shlib", "node_addon")
|
||||
obj.target = "bson"
|
||||
obj.source = ["bson.cc"]
|
||||
# obj.uselib = "NODE"
|
||||
|
||||
def shutdown():
|
||||
# HACK to get compress.node out of build directory.
|
||||
# better way to do this?
|
||||
if Options.commands['clean']:
|
||||
if exists('bson.node'): unlink('bson.node')
|
||||
else:
|
||||
if exists('build/default/bson.node') and not exists('bson.node'):
|
||||
symlink('build/default/bson.node', 'bson.node')
|
||||
339
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/binary.js
generated
vendored
Normal file
339
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/binary.js
generated
vendored
Normal file
@@ -0,0 +1,339 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
if(typeof window === 'undefined') {
|
||||
var Buffer = require('buffer').Buffer; // TODO just use global Buffer
|
||||
}
|
||||
|
||||
// Binary default subtype
|
||||
var BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @api private
|
||||
*/
|
||||
var writeStringToArray = function(data) {
|
||||
// Create a buffer
|
||||
var buffer = typeof Uint8Array != 'undefined' ? new Uint8Array(new ArrayBuffer(data.length)) : new Array(data.length);
|
||||
// Write the content to the buffer
|
||||
for(var i = 0; i < data.length; i++) {
|
||||
buffer[i] = data.charCodeAt(i);
|
||||
}
|
||||
// Write the string to the buffer
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Array ot Uint8Array to Binary String
|
||||
*
|
||||
* @ignore
|
||||
* @api private
|
||||
*/
|
||||
var convertArraytoUtf8BinaryString = function(byteArray, startIndex, endIndex) {
|
||||
var result = "";
|
||||
for(var i = startIndex; i < endIndex; i++) {
|
||||
result = result + String.fromCharCode(byteArray[i]);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* A class representation of the BSON Binary type.
|
||||
*
|
||||
* Sub types
|
||||
* - **BSON.BSON_BINARY_SUBTYPE_DEFAULT**, default BSON type.
|
||||
* - **BSON.BSON_BINARY_SUBTYPE_FUNCTION**, BSON function type.
|
||||
* - **BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY**, BSON byte array type.
|
||||
* - **BSON.BSON_BINARY_SUBTYPE_UUID**, BSON uuid type.
|
||||
* - **BSON.BSON_BINARY_SUBTYPE_MD5**, BSON md5 type.
|
||||
* - **BSON.BSON_BINARY_SUBTYPE_USER_DEFINED**, BSON user defined type.
|
||||
*
|
||||
* @class Represents the Binary BSON type.
|
||||
* @param {Buffer} buffer a buffer object containing the binary data.
|
||||
* @param {Number} [subType] the option binary type.
|
||||
* @return {Grid}
|
||||
*/
|
||||
function Binary(buffer, subType) {
|
||||
if(!(this instanceof Binary)) return new Binary(buffer, subType);
|
||||
|
||||
this._bsontype = 'Binary';
|
||||
|
||||
if(buffer instanceof Number) {
|
||||
this.sub_type = buffer;
|
||||
this.position = 0;
|
||||
} else {
|
||||
this.sub_type = subType == null ? BSON_BINARY_SUBTYPE_DEFAULT : subType;
|
||||
this.position = 0;
|
||||
}
|
||||
|
||||
if(buffer != null && !(buffer instanceof Number)) {
|
||||
// Only accept Buffer, Uint8Array or Arrays
|
||||
if(typeof buffer == 'string') {
|
||||
// Different ways of writing the length of the string for the different types
|
||||
if(typeof Buffer != 'undefined') {
|
||||
this.buffer = new Buffer(buffer);
|
||||
} else if(typeof Uint8Array != 'undefined' || (Object.prototype.toString.call(buffer) == '[object Array]')) {
|
||||
this.buffer = writeStringToArray(buffer);
|
||||
} else {
|
||||
throw new Error("only String, Buffer, Uint8Array or Array accepted");
|
||||
}
|
||||
} else {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
this.position = buffer.length;
|
||||
} else {
|
||||
if(typeof Buffer != 'undefined') {
|
||||
this.buffer = new Buffer(Binary.BUFFER_SIZE);
|
||||
} else if(typeof Uint8Array != 'undefined'){
|
||||
this.buffer = new Uint8Array(new ArrayBuffer(Binary.BUFFER_SIZE));
|
||||
} else {
|
||||
this.buffer = new Array(Binary.BUFFER_SIZE);
|
||||
}
|
||||
// Set position to start of buffer
|
||||
this.position = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates this binary with byte_value.
|
||||
*
|
||||
* @param {Character} byte_value a single byte we wish to write.
|
||||
* @api public
|
||||
*/
|
||||
Binary.prototype.put = function put(byte_value) {
|
||||
// If it's a string and a has more than one character throw an error
|
||||
if(byte_value['length'] != null && typeof byte_value != 'number' && byte_value.length != 1) throw new Error("only accepts single character String, Uint8Array or Array");
|
||||
if(typeof byte_value != 'number' && byte_value < 0 || byte_value > 255) throw new Error("only accepts number in a valid unsigned byte range 0-255");
|
||||
|
||||
// Decode the byte value once
|
||||
var decoded_byte = null;
|
||||
if(typeof byte_value == 'string') {
|
||||
decoded_byte = byte_value.charCodeAt(0);
|
||||
} else if(byte_value['length'] != null) {
|
||||
decoded_byte = byte_value[0];
|
||||
} else {
|
||||
decoded_byte = byte_value;
|
||||
}
|
||||
|
||||
if(this.buffer.length > this.position) {
|
||||
this.buffer[this.position++] = decoded_byte;
|
||||
} else {
|
||||
if(typeof Buffer != 'undefined' && Buffer.isBuffer(this.buffer)) {
|
||||
// Create additional overflow buffer
|
||||
var buffer = new Buffer(Binary.BUFFER_SIZE + this.buffer.length);
|
||||
// Combine the two buffers together
|
||||
this.buffer.copy(buffer, 0, 0, this.buffer.length);
|
||||
this.buffer = buffer;
|
||||
this.buffer[this.position++] = decoded_byte;
|
||||
} else {
|
||||
var buffer = null;
|
||||
// Create a new buffer (typed or normal array)
|
||||
if(Object.prototype.toString.call(this.buffer) == '[object Uint8Array]') {
|
||||
buffer = new Uint8Array(new ArrayBuffer(Binary.BUFFER_SIZE + this.buffer.length));
|
||||
} else {
|
||||
buffer = new Array(Binary.BUFFER_SIZE + this.buffer.length);
|
||||
}
|
||||
|
||||
// We need to copy all the content to the new array
|
||||
for(var i = 0; i < this.buffer.length; i++) {
|
||||
buffer[i] = this.buffer[i];
|
||||
}
|
||||
|
||||
// Reassign the buffer
|
||||
this.buffer = buffer;
|
||||
// Write the byte
|
||||
this.buffer[this.position++] = decoded_byte;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes a buffer or string to the binary.
|
||||
*
|
||||
* @param {Buffer|String} string a string or buffer to be written to the Binary BSON object.
|
||||
* @param {Number} offset specify the binary of where to write the content.
|
||||
* @api public
|
||||
*/
|
||||
Binary.prototype.write = function write(string, offset) {
|
||||
offset = typeof offset == 'number' ? offset : this.position;
|
||||
|
||||
// If the buffer is to small let's extend the buffer
|
||||
if(this.buffer.length < offset + string.length) {
|
||||
var buffer = null;
|
||||
// If we are in node.js
|
||||
if(typeof Buffer != 'undefined' && Buffer.isBuffer(this.buffer)) {
|
||||
buffer = new Buffer(this.buffer.length + string.length);
|
||||
this.buffer.copy(buffer, 0, 0, this.buffer.length);
|
||||
} else if(Object.prototype.toString.call(this.buffer) == '[object Uint8Array]') {
|
||||
// Create a new buffer
|
||||
buffer = new Uint8Array(new ArrayBuffer(this.buffer.length + string.length))
|
||||
// Copy the content
|
||||
for(var i = 0; i < this.position; i++) {
|
||||
buffer[i] = this.buffer[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Assign the new buffer
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
if(typeof Buffer != 'undefined' && Buffer.isBuffer(string) && Buffer.isBuffer(this.buffer)) {
|
||||
string.copy(this.buffer, offset, 0, string.length);
|
||||
this.position = (offset + string.length) > this.position ? (offset + string.length) : this.position;
|
||||
// offset = string.length
|
||||
} else if(typeof Buffer != 'undefined' && typeof string == 'string' && Buffer.isBuffer(this.buffer)) {
|
||||
this.buffer.write(string, 'binary', offset);
|
||||
this.position = (offset + string.length) > this.position ? (offset + string.length) : this.position;
|
||||
// offset = string.length;
|
||||
} else if(Object.prototype.toString.call(string) == '[object Uint8Array]'
|
||||
|| Object.prototype.toString.call(string) == '[object Array]' && typeof string != 'string') {
|
||||
for(var i = 0; i < string.length; i++) {
|
||||
this.buffer[offset++] = string[i];
|
||||
}
|
||||
|
||||
this.position = offset > this.position ? offset : this.position;
|
||||
} else if(typeof string == 'string') {
|
||||
for(var i = 0; i < string.length; i++) {
|
||||
this.buffer[offset++] = string.charCodeAt(i);
|
||||
}
|
||||
|
||||
this.position = offset > this.position ? offset : this.position;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads **length** bytes starting at **position**.
|
||||
*
|
||||
* @param {Number} position read from the given position in the Binary.
|
||||
* @param {Number} length the number of bytes to read.
|
||||
* @return {Buffer}
|
||||
* @api public
|
||||
*/
|
||||
Binary.prototype.read = function read(position, length) {
|
||||
length = length && length > 0
|
||||
? length
|
||||
: this.position;
|
||||
|
||||
// Let's return the data based on the type we have
|
||||
if(this.buffer['slice']) {
|
||||
return this.buffer.slice(position, position + length);
|
||||
} else {
|
||||
// Create a buffer to keep the result
|
||||
var buffer = typeof Uint8Array != 'undefined' ? new Uint8Array(new ArrayBuffer(length)) : new Array(length);
|
||||
for(var i = 0; i < length; i++) {
|
||||
buffer[i] = this.buffer[position++];
|
||||
}
|
||||
}
|
||||
// Return the buffer
|
||||
return buffer;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the value of this binary as a string.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
Binary.prototype.value = function value(asRaw) {
|
||||
asRaw = asRaw == null ? false : asRaw;
|
||||
|
||||
// If it's a node.js buffer object
|
||||
if(typeof Buffer != 'undefined' && Buffer.isBuffer(this.buffer)) {
|
||||
return asRaw ? this.buffer.slice(0, this.position) : this.buffer.toString('binary', 0, this.position);
|
||||
} else {
|
||||
if(asRaw) {
|
||||
// we support the slice command use it
|
||||
if(this.buffer['slice'] != null) {
|
||||
return this.buffer.slice(0, this.position);
|
||||
} else {
|
||||
// Create a new buffer to copy content to
|
||||
var newBuffer = Object.prototype.toString.call(this.buffer) == '[object Uint8Array]' ? new Uint8Array(new ArrayBuffer(this.position)) : new Array(this.position);
|
||||
// Copy content
|
||||
for(var i = 0; i < this.position; i++) {
|
||||
newBuffer[i] = this.buffer[i];
|
||||
}
|
||||
// Return the buffer
|
||||
return newBuffer;
|
||||
}
|
||||
} else {
|
||||
return convertArraytoUtf8BinaryString(this.buffer, 0, this.position);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Length.
|
||||
*
|
||||
* @return {Number} the length of the binary.
|
||||
* @api public
|
||||
*/
|
||||
Binary.prototype.length = function length() {
|
||||
return this.position;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @api private
|
||||
*/
|
||||
Binary.prototype.toJSON = function() {
|
||||
return this.buffer != null ? this.buffer.toString('base64') : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @api private
|
||||
*/
|
||||
Binary.prototype.toString = function(format) {
|
||||
return this.buffer != null ? this.buffer.slice(0, this.position).toString(format) : '';
|
||||
}
|
||||
|
||||
Binary.BUFFER_SIZE = 256;
|
||||
|
||||
/**
|
||||
* Default BSON type
|
||||
*
|
||||
* @classconstant SUBTYPE_DEFAULT
|
||||
**/
|
||||
Binary.SUBTYPE_DEFAULT = 0;
|
||||
/**
|
||||
* Function BSON type
|
||||
*
|
||||
* @classconstant SUBTYPE_DEFAULT
|
||||
**/
|
||||
Binary.SUBTYPE_FUNCTION = 1;
|
||||
/**
|
||||
* Byte Array BSON type
|
||||
*
|
||||
* @classconstant SUBTYPE_DEFAULT
|
||||
**/
|
||||
Binary.SUBTYPE_BYTE_ARRAY = 2;
|
||||
/**
|
||||
* OLD UUID BSON type
|
||||
*
|
||||
* @classconstant SUBTYPE_DEFAULT
|
||||
**/
|
||||
Binary.SUBTYPE_UUID_OLD = 3;
|
||||
/**
|
||||
* UUID BSON type
|
||||
*
|
||||
* @classconstant SUBTYPE_DEFAULT
|
||||
**/
|
||||
Binary.SUBTYPE_UUID = 4;
|
||||
/**
|
||||
* MD5 BSON type
|
||||
*
|
||||
* @classconstant SUBTYPE_DEFAULT
|
||||
**/
|
||||
Binary.SUBTYPE_MD5 = 5;
|
||||
/**
|
||||
* User BSON type
|
||||
*
|
||||
* @classconstant SUBTYPE_DEFAULT
|
||||
**/
|
||||
Binary.SUBTYPE_USER_DEFINED = 128;
|
||||
|
||||
/**
|
||||
* Expose.
|
||||
*/
|
||||
exports.Binary = Binary;
|
||||
|
||||
385
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/binary_parser.js
generated
vendored
Normal file
385
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/binary_parser.js
generated
vendored
Normal file
@@ -0,0 +1,385 @@
|
||||
/**
|
||||
* Binary Parser.
|
||||
* Jonas Raoni Soares Silva
|
||||
* http://jsfromhell.com/classes/binary-parser [v1.0]
|
||||
*/
|
||||
var chr = String.fromCharCode;
|
||||
|
||||
var maxBits = [];
|
||||
for (var i = 0; i < 64; i++) {
|
||||
maxBits[i] = Math.pow(2, i);
|
||||
}
|
||||
|
||||
function BinaryParser (bigEndian, allowExceptions) {
|
||||
if(!(this instanceof BinaryParser)) return new BinaryParser(bigEndian, allowExceptions);
|
||||
|
||||
this.bigEndian = bigEndian;
|
||||
this.allowExceptions = allowExceptions;
|
||||
};
|
||||
|
||||
BinaryParser.warn = function warn (msg) {
|
||||
if (this.allowExceptions) {
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
BinaryParser.decodeFloat = function decodeFloat (data, precisionBits, exponentBits) {
|
||||
var b = new this.Buffer(this.bigEndian, data);
|
||||
|
||||
b.checkBuffer(precisionBits + exponentBits + 1);
|
||||
|
||||
var bias = maxBits[exponentBits - 1] - 1
|
||||
, signal = b.readBits(precisionBits + exponentBits, 1)
|
||||
, exponent = b.readBits(precisionBits, exponentBits)
|
||||
, significand = 0
|
||||
, divisor = 2
|
||||
, curByte = b.buffer.length + (-precisionBits >> 3) - 1;
|
||||
|
||||
do {
|
||||
for (var byteValue = b.buffer[ ++curByte ], startBit = precisionBits % 8 || 8, mask = 1 << startBit; mask >>= 1; ( byteValue & mask ) && ( significand += 1 / divisor ), divisor *= 2 );
|
||||
} while (precisionBits -= startBit);
|
||||
|
||||
return exponent == ( bias << 1 ) + 1 ? significand ? NaN : signal ? -Infinity : +Infinity : ( 1 + signal * -2 ) * ( exponent || significand ? !exponent ? Math.pow( 2, -bias + 1 ) * significand : Math.pow( 2, exponent - bias ) * ( 1 + significand ) : 0 );
|
||||
};
|
||||
|
||||
BinaryParser.decodeInt = function decodeInt (data, bits, signed, forceBigEndian) {
|
||||
var b = new this.Buffer(this.bigEndian || forceBigEndian, data)
|
||||
, x = b.readBits(0, bits)
|
||||
, max = maxBits[bits]; //max = Math.pow( 2, bits );
|
||||
|
||||
return signed && x >= max / 2
|
||||
? x - max
|
||||
: x;
|
||||
};
|
||||
|
||||
BinaryParser.encodeFloat = function encodeFloat (data, precisionBits, exponentBits) {
|
||||
var bias = maxBits[exponentBits - 1] - 1
|
||||
, minExp = -bias + 1
|
||||
, maxExp = bias
|
||||
, minUnnormExp = minExp - precisionBits
|
||||
, n = parseFloat(data)
|
||||
, status = isNaN(n) || n == -Infinity || n == +Infinity ? n : 0
|
||||
, exp = 0
|
||||
, len = 2 * bias + 1 + precisionBits + 3
|
||||
, bin = new Array(len)
|
||||
, signal = (n = status !== 0 ? 0 : n) < 0
|
||||
, intPart = Math.floor(n = Math.abs(n))
|
||||
, floatPart = n - intPart
|
||||
, lastBit
|
||||
, rounded
|
||||
, result
|
||||
, i
|
||||
, j;
|
||||
|
||||
for (i = len; i; bin[--i] = 0);
|
||||
|
||||
for (i = bias + 2; intPart && i; bin[--i] = intPart % 2, intPart = Math.floor(intPart / 2));
|
||||
|
||||
for (i = bias + 1; floatPart > 0 && i; (bin[++i] = ((floatPart *= 2) >= 1) - 0 ) && --floatPart);
|
||||
|
||||
for (i = -1; ++i < len && !bin[i];);
|
||||
|
||||
if (bin[(lastBit = precisionBits - 1 + (i = (exp = bias + 1 - i) >= minExp && exp <= maxExp ? i + 1 : bias + 1 - (exp = minExp - 1))) + 1]) {
|
||||
if (!(rounded = bin[lastBit])) {
|
||||
for (j = lastBit + 2; !rounded && j < len; rounded = bin[j++]);
|
||||
}
|
||||
|
||||
for (j = lastBit + 1; rounded && --j >= 0; (bin[j] = !bin[j] - 0) && (rounded = 0));
|
||||
}
|
||||
|
||||
for (i = i - 2 < 0 ? -1 : i - 3; ++i < len && !bin[i];);
|
||||
|
||||
if ((exp = bias + 1 - i) >= minExp && exp <= maxExp) {
|
||||
++i;
|
||||
} else if (exp < minExp) {
|
||||
exp != bias + 1 - len && exp < minUnnormExp && this.warn("encodeFloat::float underflow");
|
||||
i = bias + 1 - (exp = minExp - 1);
|
||||
}
|
||||
|
||||
if (intPart || status !== 0) {
|
||||
this.warn(intPart ? "encodeFloat::float overflow" : "encodeFloat::" + status);
|
||||
exp = maxExp + 1;
|
||||
i = bias + 2;
|
||||
|
||||
if (status == -Infinity) {
|
||||
signal = 1;
|
||||
} else if (isNaN(status)) {
|
||||
bin[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (n = Math.abs(exp + bias), j = exponentBits + 1, result = ""; --j; result = (n % 2) + result, n = n >>= 1);
|
||||
|
||||
for (n = 0, j = 0, i = (result = (signal ? "1" : "0") + result + bin.slice(i, i + precisionBits).join("")).length, r = []; i; j = (j + 1) % 8) {
|
||||
n += (1 << j) * result.charAt(--i);
|
||||
if (j == 7) {
|
||||
r[r.length] = String.fromCharCode(n);
|
||||
n = 0;
|
||||
}
|
||||
}
|
||||
|
||||
r[r.length] = n
|
||||
? String.fromCharCode(n)
|
||||
: "";
|
||||
|
||||
return (this.bigEndian ? r.reverse() : r).join("");
|
||||
};
|
||||
|
||||
BinaryParser.encodeInt = function encodeInt (data, bits, signed, forceBigEndian) {
|
||||
var max = maxBits[bits];
|
||||
|
||||
if (data >= max || data < -(max / 2)) {
|
||||
this.warn("encodeInt::overflow");
|
||||
data = 0;
|
||||
}
|
||||
|
||||
if (data < 0) {
|
||||
data += max;
|
||||
}
|
||||
|
||||
for (var r = []; data; r[r.length] = String.fromCharCode(data % 256), data = Math.floor(data / 256));
|
||||
|
||||
for (bits = -(-bits >> 3) - r.length; bits--; r[r.length] = "\0");
|
||||
|
||||
return ((this.bigEndian || forceBigEndian) ? r.reverse() : r).join("");
|
||||
};
|
||||
|
||||
BinaryParser.toSmall = function( data ){ return this.decodeInt( data, 8, true ); };
|
||||
BinaryParser.fromSmall = function( data ){ return this.encodeInt( data, 8, true ); };
|
||||
BinaryParser.toByte = function( data ){ return this.decodeInt( data, 8, false ); };
|
||||
BinaryParser.fromByte = function( data ){ return this.encodeInt( data, 8, false ); };
|
||||
BinaryParser.toShort = function( data ){ return this.decodeInt( data, 16, true ); };
|
||||
BinaryParser.fromShort = function( data ){ return this.encodeInt( data, 16, true ); };
|
||||
BinaryParser.toWord = function( data ){ return this.decodeInt( data, 16, false ); };
|
||||
BinaryParser.fromWord = function( data ){ return this.encodeInt( data, 16, false ); };
|
||||
BinaryParser.toInt = function( data ){ return this.decodeInt( data, 32, true ); };
|
||||
BinaryParser.fromInt = function( data ){ return this.encodeInt( data, 32, true ); };
|
||||
BinaryParser.toLong = function( data ){ return this.decodeInt( data, 64, true ); };
|
||||
BinaryParser.fromLong = function( data ){ return this.encodeInt( data, 64, true ); };
|
||||
BinaryParser.toDWord = function( data ){ return this.decodeInt( data, 32, false ); };
|
||||
BinaryParser.fromDWord = function( data ){ return this.encodeInt( data, 32, false ); };
|
||||
BinaryParser.toQWord = function( data ){ return this.decodeInt( data, 64, true ); };
|
||||
BinaryParser.fromQWord = function( data ){ return this.encodeInt( data, 64, true ); };
|
||||
BinaryParser.toFloat = function( data ){ return this.decodeFloat( data, 23, 8 ); };
|
||||
BinaryParser.fromFloat = function( data ){ return this.encodeFloat( data, 23, 8 ); };
|
||||
BinaryParser.toDouble = function( data ){ return this.decodeFloat( data, 52, 11 ); };
|
||||
BinaryParser.fromDouble = function( data ){ return this.encodeFloat( data, 52, 11 ); };
|
||||
|
||||
// Factor out the encode so it can be shared by add_header and push_int32
|
||||
BinaryParser.encode_int32 = function encode_int32 (number, asArray) {
|
||||
var a, b, c, d, unsigned;
|
||||
unsigned = (number < 0) ? (number + 0x100000000) : number;
|
||||
a = Math.floor(unsigned / 0xffffff);
|
||||
unsigned &= 0xffffff;
|
||||
b = Math.floor(unsigned / 0xffff);
|
||||
unsigned &= 0xffff;
|
||||
c = Math.floor(unsigned / 0xff);
|
||||
unsigned &= 0xff;
|
||||
d = Math.floor(unsigned);
|
||||
return asArray ? [chr(a), chr(b), chr(c), chr(d)] : chr(a) + chr(b) + chr(c) + chr(d);
|
||||
};
|
||||
|
||||
BinaryParser.encode_int64 = function encode_int64 (number) {
|
||||
var a, b, c, d, e, f, g, h, unsigned;
|
||||
unsigned = (number < 0) ? (number + 0x10000000000000000) : number;
|
||||
a = Math.floor(unsigned / 0xffffffffffffff);
|
||||
unsigned &= 0xffffffffffffff;
|
||||
b = Math.floor(unsigned / 0xffffffffffff);
|
||||
unsigned &= 0xffffffffffff;
|
||||
c = Math.floor(unsigned / 0xffffffffff);
|
||||
unsigned &= 0xffffffffff;
|
||||
d = Math.floor(unsigned / 0xffffffff);
|
||||
unsigned &= 0xffffffff;
|
||||
e = Math.floor(unsigned / 0xffffff);
|
||||
unsigned &= 0xffffff;
|
||||
f = Math.floor(unsigned / 0xffff);
|
||||
unsigned &= 0xffff;
|
||||
g = Math.floor(unsigned / 0xff);
|
||||
unsigned &= 0xff;
|
||||
h = Math.floor(unsigned);
|
||||
return chr(a) + chr(b) + chr(c) + chr(d) + chr(e) + chr(f) + chr(g) + chr(h);
|
||||
};
|
||||
|
||||
/**
|
||||
* UTF8 methods
|
||||
*/
|
||||
|
||||
// Take a raw binary string and return a utf8 string
|
||||
BinaryParser.decode_utf8 = function decode_utf8 (binaryStr) {
|
||||
var len = binaryStr.length
|
||||
, decoded = ''
|
||||
, i = 0
|
||||
, c = 0
|
||||
, c1 = 0
|
||||
, c2 = 0
|
||||
, c3;
|
||||
|
||||
while (i < len) {
|
||||
c = binaryStr.charCodeAt(i);
|
||||
if (c < 128) {
|
||||
decoded += String.fromCharCode(c);
|
||||
i++;
|
||||
} else if ((c > 191) && (c < 224)) {
|
||||
c2 = binaryStr.charCodeAt(i+1);
|
||||
decoded += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
||||
i += 2;
|
||||
} else {
|
||||
c2 = binaryStr.charCodeAt(i+1);
|
||||
c3 = binaryStr.charCodeAt(i+2);
|
||||
decoded += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
|
||||
return decoded;
|
||||
};
|
||||
|
||||
// Encode a cstring
|
||||
BinaryParser.encode_cstring = function encode_cstring (s) {
|
||||
return unescape(encodeURIComponent(s)) + BinaryParser.fromByte(0);
|
||||
};
|
||||
|
||||
// Take a utf8 string and return a binary string
|
||||
BinaryParser.encode_utf8 = function encode_utf8 (s) {
|
||||
var a = ""
|
||||
, c;
|
||||
|
||||
for (var n = 0, len = s.length; n < len; n++) {
|
||||
c = s.charCodeAt(n);
|
||||
|
||||
if (c < 128) {
|
||||
a += String.fromCharCode(c);
|
||||
} else if ((c > 127) && (c < 2048)) {
|
||||
a += String.fromCharCode((c>>6) | 192) ;
|
||||
a += String.fromCharCode((c&63) | 128);
|
||||
} else {
|
||||
a += String.fromCharCode((c>>12) | 224);
|
||||
a += String.fromCharCode(((c>>6) & 63) | 128);
|
||||
a += String.fromCharCode((c&63) | 128);
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
};
|
||||
|
||||
BinaryParser.hprint = function hprint (s) {
|
||||
var number;
|
||||
|
||||
for (var i = 0, len = s.length; i < len; i++) {
|
||||
if (s.charCodeAt(i) < 32) {
|
||||
number = s.charCodeAt(i) <= 15
|
||||
? "0" + s.charCodeAt(i).toString(16)
|
||||
: s.charCodeAt(i).toString(16);
|
||||
process.stdout.write(number + " ")
|
||||
} else {
|
||||
number = s.charCodeAt(i) <= 15
|
||||
? "0" + s.charCodeAt(i).toString(16)
|
||||
: s.charCodeAt(i).toString(16);
|
||||
process.stdout.write(number + " ")
|
||||
}
|
||||
}
|
||||
|
||||
process.stdout.write("\n\n");
|
||||
};
|
||||
|
||||
BinaryParser.ilprint = function hprint (s) {
|
||||
var number;
|
||||
|
||||
for (var i = 0, len = s.length; i < len; i++) {
|
||||
if (s.charCodeAt(i) < 32) {
|
||||
number = s.charCodeAt(i) <= 15
|
||||
? "0" + s.charCodeAt(i).toString(10)
|
||||
: s.charCodeAt(i).toString(10);
|
||||
|
||||
require('util').debug(number+' : ');
|
||||
} else {
|
||||
number = s.charCodeAt(i) <= 15
|
||||
? "0" + s.charCodeAt(i).toString(10)
|
||||
: s.charCodeAt(i).toString(10);
|
||||
require('util').debug(number+' : '+ s.charAt(i));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
BinaryParser.hlprint = function hprint (s) {
|
||||
var number;
|
||||
|
||||
for (var i = 0, len = s.length; i < len; i++) {
|
||||
if (s.charCodeAt(i) < 32) {
|
||||
number = s.charCodeAt(i) <= 15
|
||||
? "0" + s.charCodeAt(i).toString(16)
|
||||
: s.charCodeAt(i).toString(16);
|
||||
require('util').debug(number+' : ');
|
||||
} else {
|
||||
number = s.charCodeAt(i) <= 15
|
||||
? "0" + s.charCodeAt(i).toString(16)
|
||||
: s.charCodeAt(i).toString(16);
|
||||
require('util').debug(number+' : '+ s.charAt(i));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* BinaryParser buffer constructor.
|
||||
*/
|
||||
function BinaryParserBuffer (bigEndian, buffer) {
|
||||
this.bigEndian = bigEndian || 0;
|
||||
this.buffer = [];
|
||||
this.setBuffer(buffer);
|
||||
};
|
||||
|
||||
BinaryParserBuffer.prototype.setBuffer = function setBuffer (data) {
|
||||
var l, i, b;
|
||||
|
||||
if (data) {
|
||||
i = l = data.length;
|
||||
b = this.buffer = new Array(l);
|
||||
for (; i; b[l - i] = data.charCodeAt(--i));
|
||||
this.bigEndian && b.reverse();
|
||||
}
|
||||
};
|
||||
|
||||
BinaryParserBuffer.prototype.hasNeededBits = function hasNeededBits (neededBits) {
|
||||
return this.buffer.length >= -(-neededBits >> 3);
|
||||
};
|
||||
|
||||
BinaryParserBuffer.prototype.checkBuffer = function checkBuffer (neededBits) {
|
||||
if (!this.hasNeededBits(neededBits)) {
|
||||
throw new Error("checkBuffer::missing bytes");
|
||||
}
|
||||
};
|
||||
|
||||
BinaryParserBuffer.prototype.readBits = function readBits (start, length) {
|
||||
//shl fix: Henri Torgemane ~1996 (compressed by Jonas Raoni)
|
||||
|
||||
function shl (a, b) {
|
||||
for (; b--; a = ((a %= 0x7fffffff + 1) & 0x40000000) == 0x40000000 ? a * 2 : (a - 0x40000000) * 2 + 0x7fffffff + 1);
|
||||
return a;
|
||||
}
|
||||
|
||||
if (start < 0 || length <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.checkBuffer(start + length);
|
||||
|
||||
var offsetLeft
|
||||
, offsetRight = start % 8
|
||||
, curByte = this.buffer.length - ( start >> 3 ) - 1
|
||||
, lastByte = this.buffer.length + ( -( start + length ) >> 3 )
|
||||
, diff = curByte - lastByte
|
||||
, sum = ((this.buffer[ curByte ] >> offsetRight) & ((1 << (diff ? 8 - offsetRight : length)) - 1)) + (diff && (offsetLeft = (start + length) % 8) ? (this.buffer[lastByte++] & ((1 << offsetLeft) - 1)) << (diff-- << 3) - offsetRight : 0);
|
||||
|
||||
for(; diff; sum += shl(this.buffer[lastByte++], (diff-- << 3) - offsetRight));
|
||||
|
||||
return sum;
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose.
|
||||
*/
|
||||
BinaryParser.Buffer = BinaryParserBuffer;
|
||||
|
||||
exports.BinaryParser = BinaryParser;
|
||||
1519
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/bson.js
generated
vendored
Normal file
1519
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/bson.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
25
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/code.js
generated
vendored
Normal file
25
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/code.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* A class representation of the BSON Code type.
|
||||
*
|
||||
* @class Represents the BSON Code type.
|
||||
* @param {String|Function} code a string or function.
|
||||
* @param {Object} [scope] an optional scope for the function.
|
||||
* @return {Code}
|
||||
*/
|
||||
function Code(code, scope) {
|
||||
if(!(this instanceof Code)) return new Code(code, scope);
|
||||
|
||||
this._bsontype = 'Code';
|
||||
this.code = code;
|
||||
this.scope = scope == null ? {} : scope;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @api private
|
||||
*/
|
||||
Code.prototype.toJSON = function() {
|
||||
return {scope:this.scope, code:this.code};
|
||||
}
|
||||
|
||||
exports.Code = Code;
|
||||
31
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/db_ref.js
generated
vendored
Normal file
31
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/db_ref.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* A class representation of the BSON DBRef type.
|
||||
*
|
||||
* @class Represents the BSON DBRef type.
|
||||
* @param {String} namespace the collection name.
|
||||
* @param {ObjectID} oid the reference ObjectID.
|
||||
* @param {String} [db] optional db name, if omitted the reference is local to the current db.
|
||||
* @return {DBRef}
|
||||
*/
|
||||
function DBRef(namespace, oid, db) {
|
||||
if(!(this instanceof DBRef)) return new DBRef(namespace, oid, db);
|
||||
|
||||
this._bsontype = 'DBRef';
|
||||
this.namespace = namespace;
|
||||
this.oid = oid;
|
||||
this.db = db;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @api private
|
||||
*/
|
||||
DBRef.prototype.toJSON = function() {
|
||||
return {
|
||||
'$ref':this.namespace,
|
||||
'$id':this.oid,
|
||||
'$db':this.db == null ? '' : this.db
|
||||
};
|
||||
}
|
||||
|
||||
exports.DBRef = DBRef;
|
||||
33
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/double.js
generated
vendored
Normal file
33
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/double.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* A class representation of the BSON Double type.
|
||||
*
|
||||
* @class Represents the BSON Double type.
|
||||
* @param {Number} value the number we want to represent as a double.
|
||||
* @return {Double}
|
||||
*/
|
||||
function Double(value) {
|
||||
if(!(this instanceof Double)) return new Double(value);
|
||||
|
||||
this._bsontype = 'Double';
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the number value.
|
||||
*
|
||||
* @return {Number} returns the wrapped double number.
|
||||
* @api public
|
||||
*/
|
||||
Double.prototype.valueOf = function() {
|
||||
return this.value;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @api private
|
||||
*/
|
||||
Double.prototype.toJSON = function() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
exports.Double = Double;
|
||||
121
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/float_parser.js
generated
vendored
Normal file
121
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/float_parser.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
// Copyright (c) 2008, Fair Oaks Labs, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the name of Fair Oaks Labs, Inc. nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//
|
||||
// Modifications to writeIEEE754 to support negative zeroes made by Brian White
|
||||
|
||||
var readIEEE754 = function(buffer, offset, endian, mLen, nBytes) {
|
||||
var e, m,
|
||||
bBE = (endian === 'big'),
|
||||
eLen = nBytes * 8 - mLen - 1,
|
||||
eMax = (1 << eLen) - 1,
|
||||
eBias = eMax >> 1,
|
||||
nBits = -7,
|
||||
i = bBE ? 0 : (nBytes - 1),
|
||||
d = bBE ? 1 : -1,
|
||||
s = buffer[offset + i];
|
||||
|
||||
i += d;
|
||||
|
||||
e = s & ((1 << (-nBits)) - 1);
|
||||
s >>= (-nBits);
|
||||
nBits += eLen;
|
||||
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
|
||||
|
||||
m = e & ((1 << (-nBits)) - 1);
|
||||
e >>= (-nBits);
|
||||
nBits += mLen;
|
||||
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
|
||||
|
||||
if (e === 0) {
|
||||
e = 1 - eBias;
|
||||
} else if (e === eMax) {
|
||||
return m ? NaN : ((s ? -1 : 1) * Infinity);
|
||||
} else {
|
||||
m = m + Math.pow(2, mLen);
|
||||
e = e - eBias;
|
||||
}
|
||||
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
||||
};
|
||||
|
||||
var writeIEEE754 = function(buffer, value, offset, endian, mLen, nBytes) {
|
||||
var e, m, c,
|
||||
bBE = (endian === 'big'),
|
||||
eLen = nBytes * 8 - mLen - 1,
|
||||
eMax = (1 << eLen) - 1,
|
||||
eBias = eMax >> 1,
|
||||
rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
|
||||
i = bBE ? (nBytes-1) : 0,
|
||||
d = bBE ? -1 : 1,
|
||||
s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
|
||||
|
||||
value = Math.abs(value);
|
||||
|
||||
if (isNaN(value) || value === Infinity) {
|
||||
m = isNaN(value) ? 1 : 0;
|
||||
e = eMax;
|
||||
} else {
|
||||
e = Math.floor(Math.log(value) / Math.LN2);
|
||||
if (value * (c = Math.pow(2, -e)) < 1) {
|
||||
e--;
|
||||
c *= 2;
|
||||
}
|
||||
if (e+eBias >= 1) {
|
||||
value += rt / c;
|
||||
} else {
|
||||
value += rt * Math.pow(2, 1 - eBias);
|
||||
}
|
||||
if (value * c >= 2) {
|
||||
e++;
|
||||
c /= 2;
|
||||
}
|
||||
|
||||
if (e + eBias >= eMax) {
|
||||
m = 0;
|
||||
e = eMax;
|
||||
} else if (e + eBias >= 1) {
|
||||
m = (value * c - 1) * Math.pow(2, mLen);
|
||||
e = e + eBias;
|
||||
} else {
|
||||
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
||||
e = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8);
|
||||
|
||||
e = (e << mLen) | m;
|
||||
eLen += mLen;
|
||||
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8);
|
||||
|
||||
buffer[offset + i - d] |= s * 128;
|
||||
};
|
||||
|
||||
exports.readIEEE754 = readIEEE754;
|
||||
exports.writeIEEE754 = writeIEEE754;
|
||||
74
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/index.js
generated
vendored
Normal file
74
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/index.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
try {
|
||||
exports.BSONPure = require('./bson');
|
||||
exports.BSONNative = require('../../ext');
|
||||
} catch(err) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
[ './binary_parser'
|
||||
, './binary'
|
||||
, './code'
|
||||
, './db_ref'
|
||||
, './double'
|
||||
, './max_key'
|
||||
, './min_key'
|
||||
, './objectid'
|
||||
, './symbol'
|
||||
, './timestamp'
|
||||
, './long'].forEach(function (path) {
|
||||
var module = require('./' + path);
|
||||
for (var i in module) {
|
||||
exports[i] = module[i];
|
||||
}
|
||||
});
|
||||
|
||||
// Exports all the classes for the NATIVE JS BSON Parser
|
||||
exports.native = function() {
|
||||
var classes = {};
|
||||
// Map all the classes
|
||||
[ './binary_parser'
|
||||
, './binary'
|
||||
, './code'
|
||||
, './db_ref'
|
||||
, './double'
|
||||
, './max_key'
|
||||
, './min_key'
|
||||
, './objectid'
|
||||
, './symbol'
|
||||
, './timestamp'
|
||||
, './long'
|
||||
, '../../ext'
|
||||
].forEach(function (path) {
|
||||
var module = require('./' + path);
|
||||
for (var i in module) {
|
||||
classes[i] = module[i];
|
||||
}
|
||||
});
|
||||
// Return classes list
|
||||
return classes;
|
||||
}
|
||||
|
||||
// Exports all the classes for the PURE JS BSON Parser
|
||||
exports.pure = function() {
|
||||
var classes = {};
|
||||
// Map all the classes
|
||||
[ './binary_parser'
|
||||
, './binary'
|
||||
, './code'
|
||||
, './db_ref'
|
||||
, './double'
|
||||
, './max_key'
|
||||
, './min_key'
|
||||
, './objectid'
|
||||
, './symbol'
|
||||
, './timestamp'
|
||||
, './long'
|
||||
, '././bson'].forEach(function (path) {
|
||||
var module = require('./' + path);
|
||||
for (var i in module) {
|
||||
classes[i] = module[i];
|
||||
}
|
||||
});
|
||||
// Return classes list
|
||||
return classes;
|
||||
}
|
||||
854
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/long.js
generated
vendored
Normal file
854
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/long.js
generated
vendored
Normal file
@@ -0,0 +1,854 @@
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Copyright 2009 Google Inc. All Rights Reserved
|
||||
|
||||
/**
|
||||
* Defines a Long class for representing a 64-bit two's-complement
|
||||
* integer value, which faithfully simulates the behavior of a Java "Long". This
|
||||
* implementation is derived from LongLib in GWT.
|
||||
*
|
||||
* Constructs a 64-bit two's-complement integer, given its low and high 32-bit
|
||||
* values as *signed* integers. See the from* functions below for more
|
||||
* convenient ways of constructing Longs.
|
||||
*
|
||||
* The internal representation of a Long is the two given signed, 32-bit values.
|
||||
* We use 32-bit pieces because these are the size of integers on which
|
||||
* Javascript performs bit-operations. For operations like addition and
|
||||
* multiplication, we split each number into 16-bit pieces, which can easily be
|
||||
* multiplied within Javascript's floating-point representation without overflow
|
||||
* or change in sign.
|
||||
*
|
||||
* In the algorithms below, we frequently reduce the negative case to the
|
||||
* positive case by negating the input(s) and then post-processing the result.
|
||||
* Note that we must ALWAYS check specially whether those values are MIN_VALUE
|
||||
* (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
|
||||
* a positive number, it overflows back into a negative). Not handling this
|
||||
* case would often result in infinite recursion.
|
||||
*
|
||||
* @class Represents the BSON Long type.
|
||||
* @param {Number} low the low (signed) 32 bits of the Long.
|
||||
* @param {Number} high the high (signed) 32 bits of the Long.
|
||||
*/
|
||||
function Long(low, high) {
|
||||
if(!(this instanceof Long)) return new Long(low, high);
|
||||
|
||||
this._bsontype = 'Long';
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
this.low_ = low | 0; // force into 32 signed bits.
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
this.high_ = high | 0; // force into 32 signed bits.
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the int value.
|
||||
*
|
||||
* @return {Number} the value, assuming it is a 32-bit integer.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.toInt = function() {
|
||||
return this.low_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the Number value.
|
||||
*
|
||||
* @return {Number} the closest floating-point representation to this value.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.toNumber = function() {
|
||||
return this.high_ * Long.TWO_PWR_32_DBL_ +
|
||||
this.getLowBitsUnsigned();
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the JSON value.
|
||||
*
|
||||
* @return {String} the JSON representation.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.toJSON = function() {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the String value.
|
||||
*
|
||||
* @param {Number} [opt_radix] the radix in which the text should be written.
|
||||
* @return {String} the textual representation of this value.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.toString = function(opt_radix) {
|
||||
var radix = opt_radix || 10;
|
||||
if (radix < 2 || 36 < radix) {
|
||||
throw Error('radix out of range: ' + radix);
|
||||
}
|
||||
|
||||
if (this.isZero()) {
|
||||
return '0';
|
||||
}
|
||||
|
||||
if (this.isNegative()) {
|
||||
if (this.equals(Long.MIN_VALUE)) {
|
||||
// We need to change the Long value before it can be negated, so we remove
|
||||
// the bottom-most digit in this base and then recurse to do the rest.
|
||||
var radixLong = Long.fromNumber(radix);
|
||||
var div = this.div(radixLong);
|
||||
var rem = div.multiply(radixLong).subtract(this);
|
||||
return div.toString(radix) + rem.toInt().toString(radix);
|
||||
} else {
|
||||
return '-' + this.negate().toString(radix);
|
||||
}
|
||||
}
|
||||
|
||||
// Do several (6) digits each time through the loop, so as to
|
||||
// minimize the calls to the very expensive emulated div.
|
||||
var radixToPower = Long.fromNumber(Math.pow(radix, 6));
|
||||
|
||||
var rem = this;
|
||||
var result = '';
|
||||
while (true) {
|
||||
var remDiv = rem.div(radixToPower);
|
||||
var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt();
|
||||
var digits = intval.toString(radix);
|
||||
|
||||
rem = remDiv;
|
||||
if (rem.isZero()) {
|
||||
return digits + result;
|
||||
} else {
|
||||
while (digits.length < 6) {
|
||||
digits = '0' + digits;
|
||||
}
|
||||
result = '' + digits + result;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the high 32-bits value.
|
||||
*
|
||||
* @return {Number} the high 32-bits as a signed value.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.getHighBits = function() {
|
||||
return this.high_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the low 32-bits value.
|
||||
*
|
||||
* @return {Number} the low 32-bits as a signed value.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.getLowBits = function() {
|
||||
return this.low_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the low unsigned 32-bits value.
|
||||
*
|
||||
* @return {Number} the low 32-bits as an unsigned value.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.getLowBitsUnsigned = function() {
|
||||
return (this.low_ >= 0) ?
|
||||
this.low_ : Long.TWO_PWR_32_DBL_ + this.low_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the number of bits needed to represent the absolute value of this Long.
|
||||
*
|
||||
* @return {Number} Returns the number of bits needed to represent the absolute value of this Long.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.getNumBitsAbs = function() {
|
||||
if (this.isNegative()) {
|
||||
if (this.equals(Long.MIN_VALUE)) {
|
||||
return 64;
|
||||
} else {
|
||||
return this.negate().getNumBitsAbs();
|
||||
}
|
||||
} else {
|
||||
var val = this.high_ != 0 ? this.high_ : this.low_;
|
||||
for (var bit = 31; bit > 0; bit--) {
|
||||
if ((val & (1 << bit)) != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this.high_ != 0 ? bit + 33 : bit + 1;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this value is zero.
|
||||
*
|
||||
* @return {Boolean} whether this value is zero.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.isZero = function() {
|
||||
return this.high_ == 0 && this.low_ == 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this value is negative.
|
||||
*
|
||||
* @return {Boolean} whether this value is negative.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.isNegative = function() {
|
||||
return this.high_ < 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this value is odd.
|
||||
*
|
||||
* @return {Boolean} whether this value is odd.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.isOdd = function() {
|
||||
return (this.low_ & 1) == 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this Long equals the other
|
||||
*
|
||||
* @param {Long} other Long to compare against.
|
||||
* @return {Boolean} whether this Long equals the other
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.equals = function(other) {
|
||||
return (this.high_ == other.high_) && (this.low_ == other.low_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this Long does not equal the other.
|
||||
*
|
||||
* @param {Long} other Long to compare against.
|
||||
* @return {Boolean} whether this Long does not equal the other.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.notEquals = function(other) {
|
||||
return (this.high_ != other.high_) || (this.low_ != other.low_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this Long is less than the other.
|
||||
*
|
||||
* @param {Long} other Long to compare against.
|
||||
* @return {Boolean} whether this Long is less than the other.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.lessThan = function(other) {
|
||||
return this.compare(other) < 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this Long is less than or equal to the other.
|
||||
*
|
||||
* @param {Long} other Long to compare against.
|
||||
* @return {Boolean} whether this Long is less than or equal to the other.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.lessThanOrEqual = function(other) {
|
||||
return this.compare(other) <= 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this Long is greater than the other.
|
||||
*
|
||||
* @param {Long} other Long to compare against.
|
||||
* @return {Boolean} whether this Long is greater than the other.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.greaterThan = function(other) {
|
||||
return this.compare(other) > 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this Long is greater than or equal to the other.
|
||||
*
|
||||
* @param {Long} other Long to compare against.
|
||||
* @return {Boolean} whether this Long is greater than or equal to the other.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.greaterThanOrEqual = function(other) {
|
||||
return this.compare(other) >= 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compares this Long with the given one.
|
||||
*
|
||||
* @param {Long} other Long to compare against.
|
||||
* @return {Boolean} 0 if they are the same, 1 if the this is greater, and -1 if the given one is greater.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.compare = function(other) {
|
||||
if (this.equals(other)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var thisNeg = this.isNegative();
|
||||
var otherNeg = other.isNegative();
|
||||
if (thisNeg && !otherNeg) {
|
||||
return -1;
|
||||
}
|
||||
if (!thisNeg && otherNeg) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// at this point, the signs are the same, so subtraction will not overflow
|
||||
if (this.subtract(other).isNegative()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The negation of this value.
|
||||
*
|
||||
* @return {Long} the negation of this value.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.negate = function() {
|
||||
if (this.equals(Long.MIN_VALUE)) {
|
||||
return Long.MIN_VALUE;
|
||||
} else {
|
||||
return this.not().add(Long.ONE);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the sum of this and the given Long.
|
||||
*
|
||||
* @param {Long} other Long to add to this one.
|
||||
* @return {Long} the sum of this and the given Long.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.add = function(other) {
|
||||
// Divide each number into 4 chunks of 16 bits, and then sum the chunks.
|
||||
|
||||
var a48 = this.high_ >>> 16;
|
||||
var a32 = this.high_ & 0xFFFF;
|
||||
var a16 = this.low_ >>> 16;
|
||||
var a00 = this.low_ & 0xFFFF;
|
||||
|
||||
var b48 = other.high_ >>> 16;
|
||||
var b32 = other.high_ & 0xFFFF;
|
||||
var b16 = other.low_ >>> 16;
|
||||
var b00 = other.low_ & 0xFFFF;
|
||||
|
||||
var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
|
||||
c00 += a00 + b00;
|
||||
c16 += c00 >>> 16;
|
||||
c00 &= 0xFFFF;
|
||||
c16 += a16 + b16;
|
||||
c32 += c16 >>> 16;
|
||||
c16 &= 0xFFFF;
|
||||
c32 += a32 + b32;
|
||||
c48 += c32 >>> 16;
|
||||
c32 &= 0xFFFF;
|
||||
c48 += a48 + b48;
|
||||
c48 &= 0xFFFF;
|
||||
return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the difference of this and the given Long.
|
||||
*
|
||||
* @param {Long} other Long to subtract from this.
|
||||
* @return {Long} the difference of this and the given Long.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.subtract = function(other) {
|
||||
return this.add(other.negate());
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the product of this and the given Long.
|
||||
*
|
||||
* @param {Long} other Long to multiply with this.
|
||||
* @return {Long} the product of this and the other.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.multiply = function(other) {
|
||||
if (this.isZero()) {
|
||||
return Long.ZERO;
|
||||
} else if (other.isZero()) {
|
||||
return Long.ZERO;
|
||||
}
|
||||
|
||||
if (this.equals(Long.MIN_VALUE)) {
|
||||
return other.isOdd() ? Long.MIN_VALUE : Long.ZERO;
|
||||
} else if (other.equals(Long.MIN_VALUE)) {
|
||||
return this.isOdd() ? Long.MIN_VALUE : Long.ZERO;
|
||||
}
|
||||
|
||||
if (this.isNegative()) {
|
||||
if (other.isNegative()) {
|
||||
return this.negate().multiply(other.negate());
|
||||
} else {
|
||||
return this.negate().multiply(other).negate();
|
||||
}
|
||||
} else if (other.isNegative()) {
|
||||
return this.multiply(other.negate()).negate();
|
||||
}
|
||||
|
||||
// If both Longs are small, use float multiplication
|
||||
if (this.lessThan(Long.TWO_PWR_24_) &&
|
||||
other.lessThan(Long.TWO_PWR_24_)) {
|
||||
return Long.fromNumber(this.toNumber() * other.toNumber());
|
||||
}
|
||||
|
||||
// Divide each Long into 4 chunks of 16 bits, and then add up 4x4 products.
|
||||
// We can skip products that would overflow.
|
||||
|
||||
var a48 = this.high_ >>> 16;
|
||||
var a32 = this.high_ & 0xFFFF;
|
||||
var a16 = this.low_ >>> 16;
|
||||
var a00 = this.low_ & 0xFFFF;
|
||||
|
||||
var b48 = other.high_ >>> 16;
|
||||
var b32 = other.high_ & 0xFFFF;
|
||||
var b16 = other.low_ >>> 16;
|
||||
var b00 = other.low_ & 0xFFFF;
|
||||
|
||||
var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
|
||||
c00 += a00 * b00;
|
||||
c16 += c00 >>> 16;
|
||||
c00 &= 0xFFFF;
|
||||
c16 += a16 * b00;
|
||||
c32 += c16 >>> 16;
|
||||
c16 &= 0xFFFF;
|
||||
c16 += a00 * b16;
|
||||
c32 += c16 >>> 16;
|
||||
c16 &= 0xFFFF;
|
||||
c32 += a32 * b00;
|
||||
c48 += c32 >>> 16;
|
||||
c32 &= 0xFFFF;
|
||||
c32 += a16 * b16;
|
||||
c48 += c32 >>> 16;
|
||||
c32 &= 0xFFFF;
|
||||
c32 += a00 * b32;
|
||||
c48 += c32 >>> 16;
|
||||
c32 &= 0xFFFF;
|
||||
c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
|
||||
c48 &= 0xFFFF;
|
||||
return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns this Long divided by the given one.
|
||||
*
|
||||
* @param {Long} other Long by which to divide.
|
||||
* @return {Long} this Long divided by the given one.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.div = function(other) {
|
||||
if (other.isZero()) {
|
||||
throw Error('division by zero');
|
||||
} else if (this.isZero()) {
|
||||
return Long.ZERO;
|
||||
}
|
||||
|
||||
if (this.equals(Long.MIN_VALUE)) {
|
||||
if (other.equals(Long.ONE) ||
|
||||
other.equals(Long.NEG_ONE)) {
|
||||
return Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
|
||||
} else if (other.equals(Long.MIN_VALUE)) {
|
||||
return Long.ONE;
|
||||
} else {
|
||||
// At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
|
||||
var halfThis = this.shiftRight(1);
|
||||
var approx = halfThis.div(other).shiftLeft(1);
|
||||
if (approx.equals(Long.ZERO)) {
|
||||
return other.isNegative() ? Long.ONE : Long.NEG_ONE;
|
||||
} else {
|
||||
var rem = this.subtract(other.multiply(approx));
|
||||
var result = approx.add(rem.div(other));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} else if (other.equals(Long.MIN_VALUE)) {
|
||||
return Long.ZERO;
|
||||
}
|
||||
|
||||
if (this.isNegative()) {
|
||||
if (other.isNegative()) {
|
||||
return this.negate().div(other.negate());
|
||||
} else {
|
||||
return this.negate().div(other).negate();
|
||||
}
|
||||
} else if (other.isNegative()) {
|
||||
return this.div(other.negate()).negate();
|
||||
}
|
||||
|
||||
// Repeat the following until the remainder is less than other: find a
|
||||
// floating-point that approximates remainder / other *from below*, add this
|
||||
// into the result, and subtract it from the remainder. It is critical that
|
||||
// the approximate value is less than or equal to the real value so that the
|
||||
// remainder never becomes negative.
|
||||
var res = Long.ZERO;
|
||||
var rem = this;
|
||||
while (rem.greaterThanOrEqual(other)) {
|
||||
// Approximate the result of division. This may be a little greater or
|
||||
// smaller than the actual value.
|
||||
var approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber()));
|
||||
|
||||
// We will tweak the approximate result by changing it in the 48-th digit or
|
||||
// the smallest non-fractional digit, whichever is larger.
|
||||
var log2 = Math.ceil(Math.log(approx) / Math.LN2);
|
||||
var delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48);
|
||||
|
||||
// Decrease the approximation until it is smaller than the remainder. Note
|
||||
// that if it is too large, the product overflows and is negative.
|
||||
var approxRes = Long.fromNumber(approx);
|
||||
var approxRem = approxRes.multiply(other);
|
||||
while (approxRem.isNegative() || approxRem.greaterThan(rem)) {
|
||||
approx -= delta;
|
||||
approxRes = Long.fromNumber(approx);
|
||||
approxRem = approxRes.multiply(other);
|
||||
}
|
||||
|
||||
// We know the answer can't be zero... and actually, zero would cause
|
||||
// infinite recursion since we would make no progress.
|
||||
if (approxRes.isZero()) {
|
||||
approxRes = Long.ONE;
|
||||
}
|
||||
|
||||
res = res.add(approxRes);
|
||||
rem = rem.subtract(approxRem);
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns this Long modulo the given one.
|
||||
*
|
||||
* @param {Long} other Long by which to mod.
|
||||
* @return {Long} this Long modulo the given one.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.modulo = function(other) {
|
||||
return this.subtract(this.div(other).multiply(other));
|
||||
};
|
||||
|
||||
/**
|
||||
* The bitwise-NOT of this value.
|
||||
*
|
||||
* @return {Long} the bitwise-NOT of this value.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.not = function() {
|
||||
return Long.fromBits(~this.low_, ~this.high_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the bitwise-AND of this Long and the given one.
|
||||
*
|
||||
* @param {Long} other the Long with which to AND.
|
||||
* @return {Long} the bitwise-AND of this and the other.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.and = function(other) {
|
||||
return Long.fromBits(this.low_ & other.low_, this.high_ & other.high_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the bitwise-OR of this Long and the given one.
|
||||
*
|
||||
* @param {Long} other the Long with which to OR.
|
||||
* @return {Long} the bitwise-OR of this and the other.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.or = function(other) {
|
||||
return Long.fromBits(this.low_ | other.low_, this.high_ | other.high_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the bitwise-XOR of this Long and the given one.
|
||||
*
|
||||
* @param {Long} other the Long with which to XOR.
|
||||
* @return {Long} the bitwise-XOR of this and the other.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.xor = function(other) {
|
||||
return Long.fromBits(this.low_ ^ other.low_, this.high_ ^ other.high_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns this Long with bits shifted to the left by the given amount.
|
||||
*
|
||||
* @param {Number} numBits the number of bits by which to shift.
|
||||
* @return {Long} this shifted to the left by the given amount.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.shiftLeft = function(numBits) {
|
||||
numBits &= 63;
|
||||
if (numBits == 0) {
|
||||
return this;
|
||||
} else {
|
||||
var low = this.low_;
|
||||
if (numBits < 32) {
|
||||
var high = this.high_;
|
||||
return Long.fromBits(
|
||||
low << numBits,
|
||||
(high << numBits) | (low >>> (32 - numBits)));
|
||||
} else {
|
||||
return Long.fromBits(0, low << (numBits - 32));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns this Long with bits shifted to the right by the given amount.
|
||||
*
|
||||
* @param {Number} numBits the number of bits by which to shift.
|
||||
* @return {Long} this shifted to the right by the given amount.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.shiftRight = function(numBits) {
|
||||
numBits &= 63;
|
||||
if (numBits == 0) {
|
||||
return this;
|
||||
} else {
|
||||
var high = this.high_;
|
||||
if (numBits < 32) {
|
||||
var low = this.low_;
|
||||
return Long.fromBits(
|
||||
(low >>> numBits) | (high << (32 - numBits)),
|
||||
high >> numBits);
|
||||
} else {
|
||||
return Long.fromBits(
|
||||
high >> (numBits - 32),
|
||||
high >= 0 ? 0 : -1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns this Long with bits shifted to the right by the given amount, with the new top bits matching the current sign bit.
|
||||
*
|
||||
* @param {Number} numBits the number of bits by which to shift.
|
||||
* @return {Long} this shifted to the right by the given amount, with zeros placed into the new leading bits.
|
||||
* @api public
|
||||
*/
|
||||
Long.prototype.shiftRightUnsigned = function(numBits) {
|
||||
numBits &= 63;
|
||||
if (numBits == 0) {
|
||||
return this;
|
||||
} else {
|
||||
var high = this.high_;
|
||||
if (numBits < 32) {
|
||||
var low = this.low_;
|
||||
return Long.fromBits(
|
||||
(low >>> numBits) | (high << (32 - numBits)),
|
||||
high >>> numBits);
|
||||
} else if (numBits == 32) {
|
||||
return Long.fromBits(high, 0);
|
||||
} else {
|
||||
return Long.fromBits(high >>> (numBits - 32), 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a Long representing the given (32-bit) integer value.
|
||||
*
|
||||
* @param {Number} value the 32-bit integer in question.
|
||||
* @return {Long} the corresponding Long value.
|
||||
* @api public
|
||||
*/
|
||||
Long.fromInt = function(value) {
|
||||
if (-128 <= value && value < 128) {
|
||||
var cachedObj = Long.INT_CACHE_[value];
|
||||
if (cachedObj) {
|
||||
return cachedObj;
|
||||
}
|
||||
}
|
||||
|
||||
var obj = new Long(value | 0, value < 0 ? -1 : 0);
|
||||
if (-128 <= value && value < 128) {
|
||||
Long.INT_CACHE_[value] = obj;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
|
||||
*
|
||||
* @param {Number} value the number in question.
|
||||
* @return {Long} the corresponding Long value.
|
||||
* @api public
|
||||
*/
|
||||
Long.fromNumber = function(value) {
|
||||
if (isNaN(value) || !isFinite(value)) {
|
||||
return Long.ZERO;
|
||||
} else if (value <= -Long.TWO_PWR_63_DBL_) {
|
||||
return Long.MIN_VALUE;
|
||||
} else if (value + 1 >= Long.TWO_PWR_63_DBL_) {
|
||||
return Long.MAX_VALUE;
|
||||
} else if (value < 0) {
|
||||
return Long.fromNumber(-value).negate();
|
||||
} else {
|
||||
return new Long(
|
||||
(value % Long.TWO_PWR_32_DBL_) | 0,
|
||||
(value / Long.TWO_PWR_32_DBL_) | 0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a Long representing the 64-bit integer that comes by concatenating the given high and low bits. Each is assumed to use 32 bits.
|
||||
*
|
||||
* @param {Number} lowBits the low 32-bits.
|
||||
* @param {Number} highBits the high 32-bits.
|
||||
* @return {Long} the corresponding Long value.
|
||||
* @api public
|
||||
*/
|
||||
Long.fromBits = function(lowBits, highBits) {
|
||||
return new Long(lowBits, highBits);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a Long representation of the given string, written using the given radix.
|
||||
*
|
||||
* @param {String} str the textual representation of the Long.
|
||||
* @param {Number} opt_radix the radix in which the text is written.
|
||||
* @return {Long} the corresponding Long value.
|
||||
* @api public
|
||||
*/
|
||||
Long.fromString = function(str, opt_radix) {
|
||||
if (str.length == 0) {
|
||||
throw Error('number format error: empty string');
|
||||
}
|
||||
|
||||
var radix = opt_radix || 10;
|
||||
if (radix < 2 || 36 < radix) {
|
||||
throw Error('radix out of range: ' + radix);
|
||||
}
|
||||
|
||||
if (str.charAt(0) == '-') {
|
||||
return Long.fromString(str.substring(1), radix).negate();
|
||||
} else if (str.indexOf('-') >= 0) {
|
||||
throw Error('number format error: interior "-" character: ' + str);
|
||||
}
|
||||
|
||||
// Do several (8) digits each time through the loop, so as to
|
||||
// minimize the calls to the very expensive emulated div.
|
||||
var radixToPower = Long.fromNumber(Math.pow(radix, 8));
|
||||
|
||||
var result = Long.ZERO;
|
||||
for (var i = 0; i < str.length; i += 8) {
|
||||
var size = Math.min(8, str.length - i);
|
||||
var value = parseInt(str.substring(i, i + size), radix);
|
||||
if (size < 8) {
|
||||
var power = Long.fromNumber(Math.pow(radix, size));
|
||||
result = result.multiply(power).add(Long.fromNumber(value));
|
||||
} else {
|
||||
result = result.multiply(radixToPower);
|
||||
result = result.add(Long.fromNumber(value));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the
|
||||
// from* methods on which they depend.
|
||||
|
||||
|
||||
/**
|
||||
* A cache of the Long representations of small integer values.
|
||||
* @type {Object}
|
||||
* @api private
|
||||
*/
|
||||
Long.INT_CACHE_ = {};
|
||||
|
||||
// NOTE: the compiler should inline these constant values below and then remove
|
||||
// these variables, so there should be no runtime penalty for these.
|
||||
|
||||
/**
|
||||
* Number used repeated below in calculations. This must appear before the
|
||||
* first call to any from* function below.
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Long.TWO_PWR_16_DBL_ = 1 << 16;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Long.TWO_PWR_24_DBL_ = 1 << 24;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Long.TWO_PWR_32_DBL_ = Long.TWO_PWR_16_DBL_ * Long.TWO_PWR_16_DBL_;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Long.TWO_PWR_31_DBL_ = Long.TWO_PWR_32_DBL_ / 2;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Long.TWO_PWR_48_DBL_ = Long.TWO_PWR_32_DBL_ * Long.TWO_PWR_16_DBL_;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Long.TWO_PWR_64_DBL_ = Long.TWO_PWR_32_DBL_ * Long.TWO_PWR_32_DBL_;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Long.TWO_PWR_63_DBL_ = Long.TWO_PWR_64_DBL_ / 2;
|
||||
|
||||
/** @type {Long} */
|
||||
Long.ZERO = Long.fromInt(0);
|
||||
|
||||
/** @type {Long} */
|
||||
Long.ONE = Long.fromInt(1);
|
||||
|
||||
/** @type {Long} */
|
||||
Long.NEG_ONE = Long.fromInt(-1);
|
||||
|
||||
/** @type {Long} */
|
||||
Long.MAX_VALUE =
|
||||
Long.fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0);
|
||||
|
||||
/** @type {Long} */
|
||||
Long.MIN_VALUE = Long.fromBits(0, 0x80000000 | 0);
|
||||
|
||||
/**
|
||||
* @type {Long}
|
||||
* @api private
|
||||
*/
|
||||
Long.TWO_PWR_24_ = Long.fromInt(1 << 24);
|
||||
|
||||
/**
|
||||
* Expose.
|
||||
*/
|
||||
exports.Long = Long;
|
||||
13
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/max_key.js
generated
vendored
Normal file
13
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/max_key.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* A class representation of the BSON MaxKey type.
|
||||
*
|
||||
* @class Represents the BSON MaxKey type.
|
||||
* @return {MaxKey}
|
||||
*/
|
||||
function MaxKey() {
|
||||
if(!(this instanceof MaxKey)) return new MaxKey();
|
||||
|
||||
this._bsontype = 'MaxKey';
|
||||
}
|
||||
|
||||
exports.MaxKey = MaxKey;
|
||||
13
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/min_key.js
generated
vendored
Normal file
13
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/min_key.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* A class representation of the BSON MinKey type.
|
||||
*
|
||||
* @class Represents the BSON MinKey type.
|
||||
* @return {MinKey}
|
||||
*/
|
||||
function MinKey() {
|
||||
if(!(this instanceof MinKey)) return new MinKey();
|
||||
|
||||
this._bsontype = 'MinKey';
|
||||
}
|
||||
|
||||
exports.MinKey = MinKey;
|
||||
253
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/objectid.js
generated
vendored
Normal file
253
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/objectid.js
generated
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var BinaryParser = require('./binary_parser').BinaryParser;
|
||||
|
||||
/**
|
||||
* Machine id.
|
||||
*
|
||||
* Create a random 3-byte value (i.e. unique for this
|
||||
* process). Other drivers use a md5 of the machine id here, but
|
||||
* that would mean an asyc call to gethostname, so we don't bother.
|
||||
*/
|
||||
var MACHINE_ID = parseInt(Math.random() * 0xFFFFFF, 10);
|
||||
|
||||
// Regular expression that checks for hex value
|
||||
var checkForHexRegExp = new RegExp("^[0-9a-fA-F]{24}$");
|
||||
|
||||
/**
|
||||
* Create a new ObjectID instance
|
||||
*
|
||||
* @class Represents the BSON ObjectID type
|
||||
* @param {String|Number} id Can be a 24 byte hex string, 12 byte binary string or a Number.
|
||||
* @return {Object} instance of ObjectID.
|
||||
*/
|
||||
var ObjectID = function ObjectID(id, _hex) {
|
||||
if(!(this instanceof ObjectID)) return new ObjectID(id, _hex);
|
||||
|
||||
this._bsontype = 'ObjectID';
|
||||
var __id = null;
|
||||
|
||||
// Throw an error if it's not a valid setup
|
||||
if(id != null && 'number' != typeof id && (id.length != 12 && id.length != 24))
|
||||
throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");
|
||||
|
||||
// Generate id based on the input
|
||||
if(id == null || typeof id == 'number') {
|
||||
// convert to 12 byte binary string
|
||||
this.id = this.generate(id);
|
||||
} else if(id != null && id.length === 12) {
|
||||
// assume 12 byte string
|
||||
this.id = id;
|
||||
} else if(checkForHexRegExp.test(id)) {
|
||||
return ObjectID.createFromHexString(id);
|
||||
} else if(!checkForHexRegExp.test(id)) {
|
||||
throw new Error("Value passed in is not a valid 24 character hex string");
|
||||
}
|
||||
|
||||
if(ObjectID.cacheHexString) this.__id = this.toHexString();
|
||||
};
|
||||
|
||||
// Allow usage of ObjectId aswell as ObjectID
|
||||
var ObjectId = ObjectID;
|
||||
|
||||
/**
|
||||
* Return the ObjectID id as a 24 byte hex string representation
|
||||
*
|
||||
* @return {String} return the 24 byte hex string representation.
|
||||
* @api public
|
||||
*/
|
||||
ObjectID.prototype.toHexString = function() {
|
||||
if(ObjectID.cacheHexString && this.__id) return this.__id;
|
||||
|
||||
var hexString = ''
|
||||
, number
|
||||
, value;
|
||||
|
||||
for (var index = 0, len = this.id.length; index < len; index++) {
|
||||
value = BinaryParser.toByte(this.id[index]);
|
||||
number = value <= 15
|
||||
? '0' + value.toString(16)
|
||||
: value.toString(16);
|
||||
hexString = hexString + number;
|
||||
}
|
||||
|
||||
if(ObjectID.cacheHexString) this.__id = hexString;
|
||||
return hexString;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the ObjectID index used in generating new ObjectID's on the driver
|
||||
*
|
||||
* @return {Number} returns next index value.
|
||||
* @api private
|
||||
*/
|
||||
ObjectID.prototype.get_inc = function() {
|
||||
return ObjectID.index = (ObjectID.index + 1) % 0xFFFFFF;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the ObjectID index used in generating new ObjectID's on the driver
|
||||
*
|
||||
* @return {Number} returns next index value.
|
||||
* @api private
|
||||
*/
|
||||
ObjectID.prototype.getInc = function() {
|
||||
return this.get_inc();
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate a 12 byte id string used in ObjectID's
|
||||
*
|
||||
* @param {Number} [time] optional parameter allowing to pass in a second based timestamp.
|
||||
* @return {String} return the 12 byte id binary string.
|
||||
* @api private
|
||||
*/
|
||||
ObjectID.prototype.generate = function(time) {
|
||||
if ('number' == typeof time) {
|
||||
var time4Bytes = BinaryParser.encodeInt(time, 32, true, true);
|
||||
/* for time-based ObjectID the bytes following the time will be zeroed */
|
||||
var machine3Bytes = BinaryParser.encodeInt(MACHINE_ID, 24, false);
|
||||
var pid2Bytes = BinaryParser.fromShort(typeof process === 'undefined' ? Math.floor(Math.random() * 100000) : process.pid);
|
||||
var index3Bytes = BinaryParser.encodeInt(this.get_inc(), 24, false, true);
|
||||
} else {
|
||||
var unixTime = parseInt(Date.now()/1000,10);
|
||||
var time4Bytes = BinaryParser.encodeInt(unixTime, 32, true, true);
|
||||
var machine3Bytes = BinaryParser.encodeInt(MACHINE_ID, 24, false);
|
||||
var pid2Bytes = BinaryParser.fromShort(typeof process === 'undefined' ? Math.floor(Math.random() * 100000) : process.pid);
|
||||
var index3Bytes = BinaryParser.encodeInt(this.get_inc(), 24, false, true);
|
||||
}
|
||||
|
||||
return time4Bytes + machine3Bytes + pid2Bytes + index3Bytes;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts the id into a 24 byte hex string for printing
|
||||
*
|
||||
* @return {String} return the 24 byte hex string representation.
|
||||
* @api private
|
||||
*/
|
||||
ObjectID.prototype.toString = function() {
|
||||
return this.toHexString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts to a string representation of this Id.
|
||||
*
|
||||
* @return {String} return the 24 byte hex string representation.
|
||||
* @api private
|
||||
*/
|
||||
ObjectID.prototype.inspect = ObjectID.prototype.toString;
|
||||
|
||||
/**
|
||||
* Converts to its JSON representation.
|
||||
*
|
||||
* @return {String} return the 24 byte hex string representation.
|
||||
* @api private
|
||||
*/
|
||||
ObjectID.prototype.toJSON = function() {
|
||||
return this.toHexString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Compares the equality of this ObjectID with `otherID`.
|
||||
*
|
||||
* @param {Object} otherID ObjectID instance to compare against.
|
||||
* @return {Bool} the result of comparing two ObjectID's
|
||||
* @api public
|
||||
*/
|
||||
ObjectID.prototype.equals = function equals (otherID) {
|
||||
var id = (otherID instanceof ObjectID || otherID.toHexString)
|
||||
? otherID.id
|
||||
: ObjectID.createFromHexString(otherID).id;
|
||||
|
||||
return this.id === id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the generation time in seconds that this ID was generated.
|
||||
*
|
||||
* @return {Number} return number of seconds in the timestamp part of the 12 byte id.
|
||||
* @api public
|
||||
*/
|
||||
ObjectID.prototype.getTimestamp = function() {
|
||||
var timestamp = new Date();
|
||||
timestamp.setTime(Math.floor(BinaryParser.decodeInt(this.id.substring(0,4), 32, true, true)) * 1000);
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @api private
|
||||
*/
|
||||
ObjectID.index = 0;
|
||||
|
||||
ObjectID.createPk = function createPk () {
|
||||
return new ObjectID();
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an ObjectID from a second based number, with the rest of the ObjectID zeroed out. Used for comparisons or sorting the ObjectID.
|
||||
*
|
||||
* @param {Number} time an integer number representing a number of seconds.
|
||||
* @return {ObjectID} return the created ObjectID
|
||||
* @api public
|
||||
*/
|
||||
ObjectID.createFromTime = function createFromTime (time) {
|
||||
var id = BinaryParser.encodeInt(time, 32, true, true) +
|
||||
BinaryParser.encodeInt(0, 64, true, true);
|
||||
return new ObjectID(id);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an ObjectID from a hex string representation of an ObjectID.
|
||||
*
|
||||
* @param {String} hexString create a ObjectID from a passed in 24 byte hexstring.
|
||||
* @return {ObjectID} return the created ObjectID
|
||||
* @api public
|
||||
*/
|
||||
ObjectID.createFromHexString = function createFromHexString (hexString) {
|
||||
// Throw an error if it's not a valid setup
|
||||
if(typeof hexString === 'undefined' || hexString != null && hexString.length != 24)
|
||||
throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");
|
||||
|
||||
var len = hexString.length;
|
||||
|
||||
if(len > 12*2) {
|
||||
throw new Error('Id cannot be longer than 12 bytes');
|
||||
}
|
||||
|
||||
var result = ''
|
||||
, string
|
||||
, number;
|
||||
|
||||
for (var index = 0; index < len; index += 2) {
|
||||
string = hexString.substr(index, 2);
|
||||
number = parseInt(string, 16);
|
||||
result += BinaryParser.fromByte(number);
|
||||
}
|
||||
|
||||
return new ObjectID(result, hexString);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
Object.defineProperty(ObjectID.prototype, "generationTime", {
|
||||
enumerable: true
|
||||
, get: function () {
|
||||
return Math.floor(BinaryParser.decodeInt(this.id.substring(0,4), 32, true, true));
|
||||
}
|
||||
, set: function (value) {
|
||||
var value = BinaryParser.encodeInt(value, 32, true, true);
|
||||
this.id = value + this.id.substr(4);
|
||||
// delete this.__id;
|
||||
this.toHexString();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Expose.
|
||||
*/
|
||||
exports.ObjectID = ObjectID;
|
||||
exports.ObjectId = ObjectID;
|
||||
48
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/symbol.js
generated
vendored
Normal file
48
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/symbol.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* A class representation of the BSON Symbol type.
|
||||
*
|
||||
* @class Represents the BSON Symbol type.
|
||||
* @param {String} value the string representing the symbol.
|
||||
* @return {Symbol}
|
||||
*/
|
||||
function Symbol(value) {
|
||||
if(!(this instanceof Symbol)) return new Symbol(value);
|
||||
this._bsontype = 'Symbol';
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the wrapped string value.
|
||||
*
|
||||
* @return {String} returns the wrapped string.
|
||||
* @api public
|
||||
*/
|
||||
Symbol.prototype.valueOf = function() {
|
||||
return this.value;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @api private
|
||||
*/
|
||||
Symbol.prototype.toString = function() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @api private
|
||||
*/
|
||||
Symbol.prototype.inspect = function() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @api private
|
||||
*/
|
||||
Symbol.prototype.toJSON = function() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
exports.Symbol = Symbol;
|
||||
853
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/timestamp.js
generated
vendored
Normal file
853
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/lib/bson/timestamp.js
generated
vendored
Normal file
@@ -0,0 +1,853 @@
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Copyright 2009 Google Inc. All Rights Reserved
|
||||
|
||||
/**
|
||||
* Defines a Timestamp class for representing a 64-bit two's-complement
|
||||
* integer value, which faithfully simulates the behavior of a Java "Timestamp". This
|
||||
* implementation is derived from TimestampLib in GWT.
|
||||
*
|
||||
* Constructs a 64-bit two's-complement integer, given its low and high 32-bit
|
||||
* values as *signed* integers. See the from* functions below for more
|
||||
* convenient ways of constructing Timestamps.
|
||||
*
|
||||
* The internal representation of a Timestamp is the two given signed, 32-bit values.
|
||||
* We use 32-bit pieces because these are the size of integers on which
|
||||
* Javascript performs bit-operations. For operations like addition and
|
||||
* multiplication, we split each number into 16-bit pieces, which can easily be
|
||||
* multiplied within Javascript's floating-point representation without overflow
|
||||
* or change in sign.
|
||||
*
|
||||
* In the algorithms below, we frequently reduce the negative case to the
|
||||
* positive case by negating the input(s) and then post-processing the result.
|
||||
* Note that we must ALWAYS check specially whether those values are MIN_VALUE
|
||||
* (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
|
||||
* a positive number, it overflows back into a negative). Not handling this
|
||||
* case would often result in infinite recursion.
|
||||
*
|
||||
* @class Represents the BSON Timestamp type.
|
||||
* @param {Number} low the low (signed) 32 bits of the Timestamp.
|
||||
* @param {Number} high the high (signed) 32 bits of the Timestamp.
|
||||
*/
|
||||
function Timestamp(low, high) {
|
||||
if(!(this instanceof Timestamp)) return new Timestamp(low, high);
|
||||
this._bsontype = 'Timestamp';
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
this.low_ = low | 0; // force into 32 signed bits.
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
this.high_ = high | 0; // force into 32 signed bits.
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the int value.
|
||||
*
|
||||
* @return {Number} the value, assuming it is a 32-bit integer.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.toInt = function() {
|
||||
return this.low_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the Number value.
|
||||
*
|
||||
* @return {Number} the closest floating-point representation to this value.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.toNumber = function() {
|
||||
return this.high_ * Timestamp.TWO_PWR_32_DBL_ +
|
||||
this.getLowBitsUnsigned();
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the JSON value.
|
||||
*
|
||||
* @return {String} the JSON representation.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.toJSON = function() {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the String value.
|
||||
*
|
||||
* @param {Number} [opt_radix] the radix in which the text should be written.
|
||||
* @return {String} the textual representation of this value.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.toString = function(opt_radix) {
|
||||
var radix = opt_radix || 10;
|
||||
if (radix < 2 || 36 < radix) {
|
||||
throw Error('radix out of range: ' + radix);
|
||||
}
|
||||
|
||||
if (this.isZero()) {
|
||||
return '0';
|
||||
}
|
||||
|
||||
if (this.isNegative()) {
|
||||
if (this.equals(Timestamp.MIN_VALUE)) {
|
||||
// We need to change the Timestamp value before it can be negated, so we remove
|
||||
// the bottom-most digit in this base and then recurse to do the rest.
|
||||
var radixTimestamp = Timestamp.fromNumber(radix);
|
||||
var div = this.div(radixTimestamp);
|
||||
var rem = div.multiply(radixTimestamp).subtract(this);
|
||||
return div.toString(radix) + rem.toInt().toString(radix);
|
||||
} else {
|
||||
return '-' + this.negate().toString(radix);
|
||||
}
|
||||
}
|
||||
|
||||
// Do several (6) digits each time through the loop, so as to
|
||||
// minimize the calls to the very expensive emulated div.
|
||||
var radixToPower = Timestamp.fromNumber(Math.pow(radix, 6));
|
||||
|
||||
var rem = this;
|
||||
var result = '';
|
||||
while (true) {
|
||||
var remDiv = rem.div(radixToPower);
|
||||
var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt();
|
||||
var digits = intval.toString(radix);
|
||||
|
||||
rem = remDiv;
|
||||
if (rem.isZero()) {
|
||||
return digits + result;
|
||||
} else {
|
||||
while (digits.length < 6) {
|
||||
digits = '0' + digits;
|
||||
}
|
||||
result = '' + digits + result;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the high 32-bits value.
|
||||
*
|
||||
* @return {Number} the high 32-bits as a signed value.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.getHighBits = function() {
|
||||
return this.high_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the low 32-bits value.
|
||||
*
|
||||
* @return {Number} the low 32-bits as a signed value.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.getLowBits = function() {
|
||||
return this.low_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the low unsigned 32-bits value.
|
||||
*
|
||||
* @return {Number} the low 32-bits as an unsigned value.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.getLowBitsUnsigned = function() {
|
||||
return (this.low_ >= 0) ?
|
||||
this.low_ : Timestamp.TWO_PWR_32_DBL_ + this.low_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the number of bits needed to represent the absolute value of this Timestamp.
|
||||
*
|
||||
* @return {Number} Returns the number of bits needed to represent the absolute value of this Timestamp.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.getNumBitsAbs = function() {
|
||||
if (this.isNegative()) {
|
||||
if (this.equals(Timestamp.MIN_VALUE)) {
|
||||
return 64;
|
||||
} else {
|
||||
return this.negate().getNumBitsAbs();
|
||||
}
|
||||
} else {
|
||||
var val = this.high_ != 0 ? this.high_ : this.low_;
|
||||
for (var bit = 31; bit > 0; bit--) {
|
||||
if ((val & (1 << bit)) != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this.high_ != 0 ? bit + 33 : bit + 1;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this value is zero.
|
||||
*
|
||||
* @return {Boolean} whether this value is zero.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.isZero = function() {
|
||||
return this.high_ == 0 && this.low_ == 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this value is negative.
|
||||
*
|
||||
* @return {Boolean} whether this value is negative.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.isNegative = function() {
|
||||
return this.high_ < 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this value is odd.
|
||||
*
|
||||
* @return {Boolean} whether this value is odd.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.isOdd = function() {
|
||||
return (this.low_ & 1) == 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this Timestamp equals the other
|
||||
*
|
||||
* @param {Timestamp} other Timestamp to compare against.
|
||||
* @return {Boolean} whether this Timestamp equals the other
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.equals = function(other) {
|
||||
return (this.high_ == other.high_) && (this.low_ == other.low_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this Timestamp does not equal the other.
|
||||
*
|
||||
* @param {Timestamp} other Timestamp to compare against.
|
||||
* @return {Boolean} whether this Timestamp does not equal the other.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.notEquals = function(other) {
|
||||
return (this.high_ != other.high_) || (this.low_ != other.low_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this Timestamp is less than the other.
|
||||
*
|
||||
* @param {Timestamp} other Timestamp to compare against.
|
||||
* @return {Boolean} whether this Timestamp is less than the other.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.lessThan = function(other) {
|
||||
return this.compare(other) < 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this Timestamp is less than or equal to the other.
|
||||
*
|
||||
* @param {Timestamp} other Timestamp to compare against.
|
||||
* @return {Boolean} whether this Timestamp is less than or equal to the other.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.lessThanOrEqual = function(other) {
|
||||
return this.compare(other) <= 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this Timestamp is greater than the other.
|
||||
*
|
||||
* @param {Timestamp} other Timestamp to compare against.
|
||||
* @return {Boolean} whether this Timestamp is greater than the other.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.greaterThan = function(other) {
|
||||
return this.compare(other) > 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether this Timestamp is greater than or equal to the other.
|
||||
*
|
||||
* @param {Timestamp} other Timestamp to compare against.
|
||||
* @return {Boolean} whether this Timestamp is greater than or equal to the other.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.greaterThanOrEqual = function(other) {
|
||||
return this.compare(other) >= 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compares this Timestamp with the given one.
|
||||
*
|
||||
* @param {Timestamp} other Timestamp to compare against.
|
||||
* @return {Boolean} 0 if they are the same, 1 if the this is greater, and -1 if the given one is greater.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.compare = function(other) {
|
||||
if (this.equals(other)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var thisNeg = this.isNegative();
|
||||
var otherNeg = other.isNegative();
|
||||
if (thisNeg && !otherNeg) {
|
||||
return -1;
|
||||
}
|
||||
if (!thisNeg && otherNeg) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// at this point, the signs are the same, so subtraction will not overflow
|
||||
if (this.subtract(other).isNegative()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The negation of this value.
|
||||
*
|
||||
* @return {Timestamp} the negation of this value.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.negate = function() {
|
||||
if (this.equals(Timestamp.MIN_VALUE)) {
|
||||
return Timestamp.MIN_VALUE;
|
||||
} else {
|
||||
return this.not().add(Timestamp.ONE);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the sum of this and the given Timestamp.
|
||||
*
|
||||
* @param {Timestamp} other Timestamp to add to this one.
|
||||
* @return {Timestamp} the sum of this and the given Timestamp.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.add = function(other) {
|
||||
// Divide each number into 4 chunks of 16 bits, and then sum the chunks.
|
||||
|
||||
var a48 = this.high_ >>> 16;
|
||||
var a32 = this.high_ & 0xFFFF;
|
||||
var a16 = this.low_ >>> 16;
|
||||
var a00 = this.low_ & 0xFFFF;
|
||||
|
||||
var b48 = other.high_ >>> 16;
|
||||
var b32 = other.high_ & 0xFFFF;
|
||||
var b16 = other.low_ >>> 16;
|
||||
var b00 = other.low_ & 0xFFFF;
|
||||
|
||||
var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
|
||||
c00 += a00 + b00;
|
||||
c16 += c00 >>> 16;
|
||||
c00 &= 0xFFFF;
|
||||
c16 += a16 + b16;
|
||||
c32 += c16 >>> 16;
|
||||
c16 &= 0xFFFF;
|
||||
c32 += a32 + b32;
|
||||
c48 += c32 >>> 16;
|
||||
c32 &= 0xFFFF;
|
||||
c48 += a48 + b48;
|
||||
c48 &= 0xFFFF;
|
||||
return Timestamp.fromBits((c16 << 16) | c00, (c48 << 16) | c32);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the difference of this and the given Timestamp.
|
||||
*
|
||||
* @param {Timestamp} other Timestamp to subtract from this.
|
||||
* @return {Timestamp} the difference of this and the given Timestamp.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.subtract = function(other) {
|
||||
return this.add(other.negate());
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the product of this and the given Timestamp.
|
||||
*
|
||||
* @param {Timestamp} other Timestamp to multiply with this.
|
||||
* @return {Timestamp} the product of this and the other.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.multiply = function(other) {
|
||||
if (this.isZero()) {
|
||||
return Timestamp.ZERO;
|
||||
} else if (other.isZero()) {
|
||||
return Timestamp.ZERO;
|
||||
}
|
||||
|
||||
if (this.equals(Timestamp.MIN_VALUE)) {
|
||||
return other.isOdd() ? Timestamp.MIN_VALUE : Timestamp.ZERO;
|
||||
} else if (other.equals(Timestamp.MIN_VALUE)) {
|
||||
return this.isOdd() ? Timestamp.MIN_VALUE : Timestamp.ZERO;
|
||||
}
|
||||
|
||||
if (this.isNegative()) {
|
||||
if (other.isNegative()) {
|
||||
return this.negate().multiply(other.negate());
|
||||
} else {
|
||||
return this.negate().multiply(other).negate();
|
||||
}
|
||||
} else if (other.isNegative()) {
|
||||
return this.multiply(other.negate()).negate();
|
||||
}
|
||||
|
||||
// If both Timestamps are small, use float multiplication
|
||||
if (this.lessThan(Timestamp.TWO_PWR_24_) &&
|
||||
other.lessThan(Timestamp.TWO_PWR_24_)) {
|
||||
return Timestamp.fromNumber(this.toNumber() * other.toNumber());
|
||||
}
|
||||
|
||||
// Divide each Timestamp into 4 chunks of 16 bits, and then add up 4x4 products.
|
||||
// We can skip products that would overflow.
|
||||
|
||||
var a48 = this.high_ >>> 16;
|
||||
var a32 = this.high_ & 0xFFFF;
|
||||
var a16 = this.low_ >>> 16;
|
||||
var a00 = this.low_ & 0xFFFF;
|
||||
|
||||
var b48 = other.high_ >>> 16;
|
||||
var b32 = other.high_ & 0xFFFF;
|
||||
var b16 = other.low_ >>> 16;
|
||||
var b00 = other.low_ & 0xFFFF;
|
||||
|
||||
var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
|
||||
c00 += a00 * b00;
|
||||
c16 += c00 >>> 16;
|
||||
c00 &= 0xFFFF;
|
||||
c16 += a16 * b00;
|
||||
c32 += c16 >>> 16;
|
||||
c16 &= 0xFFFF;
|
||||
c16 += a00 * b16;
|
||||
c32 += c16 >>> 16;
|
||||
c16 &= 0xFFFF;
|
||||
c32 += a32 * b00;
|
||||
c48 += c32 >>> 16;
|
||||
c32 &= 0xFFFF;
|
||||
c32 += a16 * b16;
|
||||
c48 += c32 >>> 16;
|
||||
c32 &= 0xFFFF;
|
||||
c32 += a00 * b32;
|
||||
c48 += c32 >>> 16;
|
||||
c32 &= 0xFFFF;
|
||||
c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
|
||||
c48 &= 0xFFFF;
|
||||
return Timestamp.fromBits((c16 << 16) | c00, (c48 << 16) | c32);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns this Timestamp divided by the given one.
|
||||
*
|
||||
* @param {Timestamp} other Timestamp by which to divide.
|
||||
* @return {Timestamp} this Timestamp divided by the given one.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.div = function(other) {
|
||||
if (other.isZero()) {
|
||||
throw Error('division by zero');
|
||||
} else if (this.isZero()) {
|
||||
return Timestamp.ZERO;
|
||||
}
|
||||
|
||||
if (this.equals(Timestamp.MIN_VALUE)) {
|
||||
if (other.equals(Timestamp.ONE) ||
|
||||
other.equals(Timestamp.NEG_ONE)) {
|
||||
return Timestamp.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
|
||||
} else if (other.equals(Timestamp.MIN_VALUE)) {
|
||||
return Timestamp.ONE;
|
||||
} else {
|
||||
// At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
|
||||
var halfThis = this.shiftRight(1);
|
||||
var approx = halfThis.div(other).shiftLeft(1);
|
||||
if (approx.equals(Timestamp.ZERO)) {
|
||||
return other.isNegative() ? Timestamp.ONE : Timestamp.NEG_ONE;
|
||||
} else {
|
||||
var rem = this.subtract(other.multiply(approx));
|
||||
var result = approx.add(rem.div(other));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} else if (other.equals(Timestamp.MIN_VALUE)) {
|
||||
return Timestamp.ZERO;
|
||||
}
|
||||
|
||||
if (this.isNegative()) {
|
||||
if (other.isNegative()) {
|
||||
return this.negate().div(other.negate());
|
||||
} else {
|
||||
return this.negate().div(other).negate();
|
||||
}
|
||||
} else if (other.isNegative()) {
|
||||
return this.div(other.negate()).negate();
|
||||
}
|
||||
|
||||
// Repeat the following until the remainder is less than other: find a
|
||||
// floating-point that approximates remainder / other *from below*, add this
|
||||
// into the result, and subtract it from the remainder. It is critical that
|
||||
// the approximate value is less than or equal to the real value so that the
|
||||
// remainder never becomes negative.
|
||||
var res = Timestamp.ZERO;
|
||||
var rem = this;
|
||||
while (rem.greaterThanOrEqual(other)) {
|
||||
// Approximate the result of division. This may be a little greater or
|
||||
// smaller than the actual value.
|
||||
var approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber()));
|
||||
|
||||
// We will tweak the approximate result by changing it in the 48-th digit or
|
||||
// the smallest non-fractional digit, whichever is larger.
|
||||
var log2 = Math.ceil(Math.log(approx) / Math.LN2);
|
||||
var delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48);
|
||||
|
||||
// Decrease the approximation until it is smaller than the remainder. Note
|
||||
// that if it is too large, the product overflows and is negative.
|
||||
var approxRes = Timestamp.fromNumber(approx);
|
||||
var approxRem = approxRes.multiply(other);
|
||||
while (approxRem.isNegative() || approxRem.greaterThan(rem)) {
|
||||
approx -= delta;
|
||||
approxRes = Timestamp.fromNumber(approx);
|
||||
approxRem = approxRes.multiply(other);
|
||||
}
|
||||
|
||||
// We know the answer can't be zero... and actually, zero would cause
|
||||
// infinite recursion since we would make no progress.
|
||||
if (approxRes.isZero()) {
|
||||
approxRes = Timestamp.ONE;
|
||||
}
|
||||
|
||||
res = res.add(approxRes);
|
||||
rem = rem.subtract(approxRem);
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns this Timestamp modulo the given one.
|
||||
*
|
||||
* @param {Timestamp} other Timestamp by which to mod.
|
||||
* @return {Timestamp} this Timestamp modulo the given one.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.modulo = function(other) {
|
||||
return this.subtract(this.div(other).multiply(other));
|
||||
};
|
||||
|
||||
/**
|
||||
* The bitwise-NOT of this value.
|
||||
*
|
||||
* @return {Timestamp} the bitwise-NOT of this value.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.not = function() {
|
||||
return Timestamp.fromBits(~this.low_, ~this.high_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the bitwise-AND of this Timestamp and the given one.
|
||||
*
|
||||
* @param {Timestamp} other the Timestamp with which to AND.
|
||||
* @return {Timestamp} the bitwise-AND of this and the other.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.and = function(other) {
|
||||
return Timestamp.fromBits(this.low_ & other.low_, this.high_ & other.high_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the bitwise-OR of this Timestamp and the given one.
|
||||
*
|
||||
* @param {Timestamp} other the Timestamp with which to OR.
|
||||
* @return {Timestamp} the bitwise-OR of this and the other.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.or = function(other) {
|
||||
return Timestamp.fromBits(this.low_ | other.low_, this.high_ | other.high_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the bitwise-XOR of this Timestamp and the given one.
|
||||
*
|
||||
* @param {Timestamp} other the Timestamp with which to XOR.
|
||||
* @return {Timestamp} the bitwise-XOR of this and the other.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.xor = function(other) {
|
||||
return Timestamp.fromBits(this.low_ ^ other.low_, this.high_ ^ other.high_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns this Timestamp with bits shifted to the left by the given amount.
|
||||
*
|
||||
* @param {Number} numBits the number of bits by which to shift.
|
||||
* @return {Timestamp} this shifted to the left by the given amount.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.shiftLeft = function(numBits) {
|
||||
numBits &= 63;
|
||||
if (numBits == 0) {
|
||||
return this;
|
||||
} else {
|
||||
var low = this.low_;
|
||||
if (numBits < 32) {
|
||||
var high = this.high_;
|
||||
return Timestamp.fromBits(
|
||||
low << numBits,
|
||||
(high << numBits) | (low >>> (32 - numBits)));
|
||||
} else {
|
||||
return Timestamp.fromBits(0, low << (numBits - 32));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns this Timestamp with bits shifted to the right by the given amount.
|
||||
*
|
||||
* @param {Number} numBits the number of bits by which to shift.
|
||||
* @return {Timestamp} this shifted to the right by the given amount.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.shiftRight = function(numBits) {
|
||||
numBits &= 63;
|
||||
if (numBits == 0) {
|
||||
return this;
|
||||
} else {
|
||||
var high = this.high_;
|
||||
if (numBits < 32) {
|
||||
var low = this.low_;
|
||||
return Timestamp.fromBits(
|
||||
(low >>> numBits) | (high << (32 - numBits)),
|
||||
high >> numBits);
|
||||
} else {
|
||||
return Timestamp.fromBits(
|
||||
high >> (numBits - 32),
|
||||
high >= 0 ? 0 : -1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns this Timestamp with bits shifted to the right by the given amount, with the new top bits matching the current sign bit.
|
||||
*
|
||||
* @param {Number} numBits the number of bits by which to shift.
|
||||
* @return {Timestamp} this shifted to the right by the given amount, with zeros placed into the new leading bits.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.prototype.shiftRightUnsigned = function(numBits) {
|
||||
numBits &= 63;
|
||||
if (numBits == 0) {
|
||||
return this;
|
||||
} else {
|
||||
var high = this.high_;
|
||||
if (numBits < 32) {
|
||||
var low = this.low_;
|
||||
return Timestamp.fromBits(
|
||||
(low >>> numBits) | (high << (32 - numBits)),
|
||||
high >>> numBits);
|
||||
} else if (numBits == 32) {
|
||||
return Timestamp.fromBits(high, 0);
|
||||
} else {
|
||||
return Timestamp.fromBits(high >>> (numBits - 32), 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a Timestamp representing the given (32-bit) integer value.
|
||||
*
|
||||
* @param {Number} value the 32-bit integer in question.
|
||||
* @return {Timestamp} the corresponding Timestamp value.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.fromInt = function(value) {
|
||||
if (-128 <= value && value < 128) {
|
||||
var cachedObj = Timestamp.INT_CACHE_[value];
|
||||
if (cachedObj) {
|
||||
return cachedObj;
|
||||
}
|
||||
}
|
||||
|
||||
var obj = new Timestamp(value | 0, value < 0 ? -1 : 0);
|
||||
if (-128 <= value && value < 128) {
|
||||
Timestamp.INT_CACHE_[value] = obj;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a Timestamp representing the given value, provided that it is a finite number. Otherwise, zero is returned.
|
||||
*
|
||||
* @param {Number} value the number in question.
|
||||
* @return {Timestamp} the corresponding Timestamp value.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.fromNumber = function(value) {
|
||||
if (isNaN(value) || !isFinite(value)) {
|
||||
return Timestamp.ZERO;
|
||||
} else if (value <= -Timestamp.TWO_PWR_63_DBL_) {
|
||||
return Timestamp.MIN_VALUE;
|
||||
} else if (value + 1 >= Timestamp.TWO_PWR_63_DBL_) {
|
||||
return Timestamp.MAX_VALUE;
|
||||
} else if (value < 0) {
|
||||
return Timestamp.fromNumber(-value).negate();
|
||||
} else {
|
||||
return new Timestamp(
|
||||
(value % Timestamp.TWO_PWR_32_DBL_) | 0,
|
||||
(value / Timestamp.TWO_PWR_32_DBL_) | 0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a Timestamp representing the 64-bit integer that comes by concatenating the given high and low bits. Each is assumed to use 32 bits.
|
||||
*
|
||||
* @param {Number} lowBits the low 32-bits.
|
||||
* @param {Number} highBits the high 32-bits.
|
||||
* @return {Timestamp} the corresponding Timestamp value.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.fromBits = function(lowBits, highBits) {
|
||||
return new Timestamp(lowBits, highBits);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a Timestamp representation of the given string, written using the given radix.
|
||||
*
|
||||
* @param {String} str the textual representation of the Timestamp.
|
||||
* @param {Number} opt_radix the radix in which the text is written.
|
||||
* @return {Timestamp} the corresponding Timestamp value.
|
||||
* @api public
|
||||
*/
|
||||
Timestamp.fromString = function(str, opt_radix) {
|
||||
if (str.length == 0) {
|
||||
throw Error('number format error: empty string');
|
||||
}
|
||||
|
||||
var radix = opt_radix || 10;
|
||||
if (radix < 2 || 36 < radix) {
|
||||
throw Error('radix out of range: ' + radix);
|
||||
}
|
||||
|
||||
if (str.charAt(0) == '-') {
|
||||
return Timestamp.fromString(str.substring(1), radix).negate();
|
||||
} else if (str.indexOf('-') >= 0) {
|
||||
throw Error('number format error: interior "-" character: ' + str);
|
||||
}
|
||||
|
||||
// Do several (8) digits each time through the loop, so as to
|
||||
// minimize the calls to the very expensive emulated div.
|
||||
var radixToPower = Timestamp.fromNumber(Math.pow(radix, 8));
|
||||
|
||||
var result = Timestamp.ZERO;
|
||||
for (var i = 0; i < str.length; i += 8) {
|
||||
var size = Math.min(8, str.length - i);
|
||||
var value = parseInt(str.substring(i, i + size), radix);
|
||||
if (size < 8) {
|
||||
var power = Timestamp.fromNumber(Math.pow(radix, size));
|
||||
result = result.multiply(power).add(Timestamp.fromNumber(value));
|
||||
} else {
|
||||
result = result.multiply(radixToPower);
|
||||
result = result.add(Timestamp.fromNumber(value));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the
|
||||
// from* methods on which they depend.
|
||||
|
||||
|
||||
/**
|
||||
* A cache of the Timestamp representations of small integer values.
|
||||
* @type {Object}
|
||||
* @api private
|
||||
*/
|
||||
Timestamp.INT_CACHE_ = {};
|
||||
|
||||
// NOTE: the compiler should inline these constant values below and then remove
|
||||
// these variables, so there should be no runtime penalty for these.
|
||||
|
||||
/**
|
||||
* Number used repeated below in calculations. This must appear before the
|
||||
* first call to any from* function below.
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Timestamp.TWO_PWR_16_DBL_ = 1 << 16;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Timestamp.TWO_PWR_24_DBL_ = 1 << 24;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Timestamp.TWO_PWR_32_DBL_ = Timestamp.TWO_PWR_16_DBL_ * Timestamp.TWO_PWR_16_DBL_;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Timestamp.TWO_PWR_31_DBL_ = Timestamp.TWO_PWR_32_DBL_ / 2;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Timestamp.TWO_PWR_48_DBL_ = Timestamp.TWO_PWR_32_DBL_ * Timestamp.TWO_PWR_16_DBL_;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Timestamp.TWO_PWR_64_DBL_ = Timestamp.TWO_PWR_32_DBL_ * Timestamp.TWO_PWR_32_DBL_;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @api private
|
||||
*/
|
||||
Timestamp.TWO_PWR_63_DBL_ = Timestamp.TWO_PWR_64_DBL_ / 2;
|
||||
|
||||
/** @type {Timestamp} */
|
||||
Timestamp.ZERO = Timestamp.fromInt(0);
|
||||
|
||||
/** @type {Timestamp} */
|
||||
Timestamp.ONE = Timestamp.fromInt(1);
|
||||
|
||||
/** @type {Timestamp} */
|
||||
Timestamp.NEG_ONE = Timestamp.fromInt(-1);
|
||||
|
||||
/** @type {Timestamp} */
|
||||
Timestamp.MAX_VALUE =
|
||||
Timestamp.fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0);
|
||||
|
||||
/** @type {Timestamp} */
|
||||
Timestamp.MIN_VALUE = Timestamp.fromBits(0, 0x80000000 | 0);
|
||||
|
||||
/**
|
||||
* @type {Timestamp}
|
||||
* @api private
|
||||
*/
|
||||
Timestamp.TWO_PWR_24_ = Timestamp.fromInt(1 << 24);
|
||||
|
||||
/**
|
||||
* Expose.
|
||||
*/
|
||||
exports.Timestamp = Timestamp;
|
||||
51
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/package.json
generated
vendored
Normal file
51
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/package.json
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "bson",
|
||||
"description": "A bson parser for node.js and the browser",
|
||||
"keywords": [
|
||||
"mongodb",
|
||||
"bson",
|
||||
"parser"
|
||||
],
|
||||
"version": "0.1.8",
|
||||
"author": {
|
||||
"name": "Christian Amor Kvalheim",
|
||||
"email": "christkv@gmail.com"
|
||||
},
|
||||
"contributors": [],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mongodb/js-bson.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mongodb/js-bson/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodeunit": "0.7.3",
|
||||
"gleak": "0.2.3",
|
||||
"one": "latest"
|
||||
},
|
||||
"config": {
|
||||
"native": false
|
||||
},
|
||||
"main": "./lib/bson/index",
|
||||
"directories": {
|
||||
"lib": "./lib/bson"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6.19"
|
||||
},
|
||||
"scripts": {
|
||||
"install": "(node-gyp rebuild 2> builderror.log) || (exit 0)",
|
||||
"test": "nodeunit ./test/node && TEST_NATIVE=TRUE nodeunit ./test/node"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "Apache License, Version 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0"
|
||||
}
|
||||
],
|
||||
"readme": "A JS/C++ Bson parser for node, used in the MongoDB Native driver",
|
||||
"readmeFilename": "README.md",
|
||||
"_id": "bson@0.1.8",
|
||||
"_from": "bson@0.1.8"
|
||||
}
|
||||
19
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/browser/browser_example.htm
generated
vendored
Normal file
19
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/browser/browser_example.htm
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<head>
|
||||
<script src="https://raw.github.com/mongodb/js-bson/master/browser_build/bson.js">
|
||||
</script>
|
||||
</head>
|
||||
<body onload="start();">
|
||||
<script>
|
||||
function start() {
|
||||
var BSON = bson().BSON;
|
||||
var Long = bson().Long;
|
||||
|
||||
var doc = {long: Long.fromNumber(100)}
|
||||
|
||||
// Serialize a document
|
||||
var data = BSON.serialize(doc, false, true, false);
|
||||
// De serialize it again
|
||||
var doc_2 = BSON.deserialize(data);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
260
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/browser/bson_test.js
generated
vendored
Normal file
260
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/browser/bson_test.js
generated
vendored
Normal file
@@ -0,0 +1,260 @@
|
||||
this.bson_test = {
|
||||
'Full document serialization and deserialization': function (test) {
|
||||
var motherOfAllDocuments = {
|
||||
'string': "客家话",
|
||||
'array': [1,2,3],
|
||||
'hash': {'a':1, 'b':2},
|
||||
'date': new Date(),
|
||||
'oid': new ObjectID(),
|
||||
'binary': new Binary('hello world'),
|
||||
'int': 42,
|
||||
'float': 33.3333,
|
||||
'regexp': /regexp/,
|
||||
'boolean': true,
|
||||
'long': Long.fromNumber(100),
|
||||
'where': new Code('this.a > i', {i:1}),
|
||||
'dbref': new DBRef('namespace', new ObjectID(), 'integration_tests_'),
|
||||
'minkey': new MinKey(),
|
||||
'maxkey': new MaxKey()
|
||||
}
|
||||
|
||||
// Let's serialize it
|
||||
var data = BSON.serialize(motherOfAllDocuments, true, true, false);
|
||||
// Deserialize the object
|
||||
var object = BSON.deserialize(data);
|
||||
|
||||
// Asserts
|
||||
test.equal(Utf8.decode(motherOfAllDocuments.string), object.string);
|
||||
test.deepEqual(motherOfAllDocuments.array, object.array);
|
||||
test.deepEqual(motherOfAllDocuments.date, object.date);
|
||||
test.deepEqual(motherOfAllDocuments.oid.toHexString(), object.oid.toHexString());
|
||||
test.deepEqual(motherOfAllDocuments.binary.length(), object.binary.length());
|
||||
test.ok(assertArrayEqual(motherOfAllDocuments.binary.value(true), object.binary.value(true)));
|
||||
test.deepEqual(motherOfAllDocuments.int, object.int);
|
||||
test.deepEqual(motherOfAllDocuments.float, object.float);
|
||||
test.deepEqual(motherOfAllDocuments.regexp, object.regexp);
|
||||
test.deepEqual(motherOfAllDocuments.boolean, object.boolean);
|
||||
test.deepEqual(motherOfAllDocuments.long.toNumber(), object.long);
|
||||
test.deepEqual(motherOfAllDocuments.where, object.where);
|
||||
test.deepEqual(motherOfAllDocuments.dbref.oid.toHexString(), object.dbref.oid.toHexString());
|
||||
test.deepEqual(motherOfAllDocuments.dbref.namespace, object.dbref.namespace);
|
||||
test.deepEqual(motherOfAllDocuments.dbref.db, object.dbref.db);
|
||||
test.deepEqual(motherOfAllDocuments.minkey, object.minkey);
|
||||
test.deepEqual(motherOfAllDocuments.maxkey, object.maxkey);
|
||||
test.done();
|
||||
},
|
||||
|
||||
'exercise all the binary object constructor methods': function (test) {
|
||||
// Construct using array
|
||||
var string = 'hello world';
|
||||
// String to array
|
||||
var array = stringToArrayBuffer(string);
|
||||
|
||||
// Binary from array buffer
|
||||
var binary = new Binary(stringToArrayBuffer(string));
|
||||
test.ok(string.length, binary.buffer.length);
|
||||
test.ok(assertArrayEqual(array, binary.buffer));
|
||||
|
||||
// Construct using number of chars
|
||||
binary = new Binary(5);
|
||||
test.ok(5, binary.buffer.length);
|
||||
|
||||
// Construct using an Array
|
||||
var binary = new Binary(stringToArray(string));
|
||||
test.ok(string.length, binary.buffer.length);
|
||||
test.ok(assertArrayEqual(array, binary.buffer));
|
||||
|
||||
// Construct using a string
|
||||
var binary = new Binary(string);
|
||||
test.ok(string.length, binary.buffer.length);
|
||||
test.ok(assertArrayEqual(array, binary.buffer));
|
||||
test.done();
|
||||
},
|
||||
|
||||
'exercise the put binary object method for an instance when using Uint8Array': function (test) {
|
||||
// Construct using array
|
||||
var string = 'hello world';
|
||||
// String to array
|
||||
var array = stringToArrayBuffer(string + 'a');
|
||||
|
||||
// Binary from array buffer
|
||||
var binary = new Binary(stringToArrayBuffer(string));
|
||||
test.ok(string.length, binary.buffer.length);
|
||||
|
||||
// Write a byte to the array
|
||||
binary.put('a')
|
||||
|
||||
// Verify that the data was writtencorrectly
|
||||
test.equal(string.length + 1, binary.position);
|
||||
test.ok(assertArrayEqual(array, binary.value(true)));
|
||||
test.equal('hello worlda', binary.value());
|
||||
|
||||
// Exercise a binary with lots of space in the buffer
|
||||
var binary = new Binary();
|
||||
test.ok(Binary.BUFFER_SIZE, binary.buffer.length);
|
||||
|
||||
// Write a byte to the array
|
||||
binary.put('a')
|
||||
|
||||
// Verify that the data was writtencorrectly
|
||||
test.equal(1, binary.position);
|
||||
test.ok(assertArrayEqual(['a'.charCodeAt(0)], binary.value(true)));
|
||||
test.equal('a', binary.value());
|
||||
test.done();
|
||||
},
|
||||
|
||||
'exercise the write binary object method for an instance when using Uint8Array': function (test) {
|
||||
// Construct using array
|
||||
var string = 'hello world';
|
||||
// Array
|
||||
var writeArrayBuffer = new Uint8Array(new ArrayBuffer(1));
|
||||
writeArrayBuffer[0] = 'a'.charCodeAt(0);
|
||||
var arrayBuffer = ['a'.charCodeAt(0)];
|
||||
|
||||
// Binary from array buffer
|
||||
var binary = new Binary(stringToArrayBuffer(string));
|
||||
test.ok(string.length, binary.buffer.length);
|
||||
|
||||
// Write a string starting at end of buffer
|
||||
binary.write('a');
|
||||
test.equal('hello worlda', binary.value());
|
||||
// Write a string starting at index 0
|
||||
binary.write('a', 0);
|
||||
test.equal('aello worlda', binary.value());
|
||||
// Write a arraybuffer starting at end of buffer
|
||||
binary.write(writeArrayBuffer);
|
||||
test.equal('aello worldaa', binary.value());
|
||||
// Write a arraybuffer starting at position 5
|
||||
binary.write(writeArrayBuffer, 5);
|
||||
test.equal('aelloaworldaa', binary.value());
|
||||
// Write a array starting at end of buffer
|
||||
binary.write(arrayBuffer);
|
||||
test.equal('aelloaworldaaa', binary.value());
|
||||
// Write a array starting at position 6
|
||||
binary.write(arrayBuffer, 6);
|
||||
test.equal('aelloaaorldaaa', binary.value());
|
||||
test.done();
|
||||
},
|
||||
|
||||
'exercise the read binary object method for an instance when using Uint8Array': function (test) {
|
||||
// Construct using array
|
||||
var string = 'hello world';
|
||||
var array = stringToArrayBuffer(string);
|
||||
|
||||
// Binary from array buffer
|
||||
var binary = new Binary(stringToArrayBuffer(string));
|
||||
test.ok(string.length, binary.buffer.length);
|
||||
|
||||
// Read the first 2 bytes
|
||||
var data = binary.read(0, 2);
|
||||
test.ok(assertArrayEqual(stringToArrayBuffer('he'), data));
|
||||
|
||||
// Read the entire field
|
||||
var data = binary.read(0);
|
||||
test.ok(assertArrayEqual(stringToArrayBuffer(string), data));
|
||||
|
||||
// Read 3 bytes
|
||||
var data = binary.read(6, 5);
|
||||
test.ok(assertArrayEqual(stringToArrayBuffer('world'), data));
|
||||
test.done();
|
||||
},
|
||||
|
||||
'Should correctly handle toBson function for an object': function(test) {
|
||||
// Test object
|
||||
var doc = {
|
||||
hello: new ObjectID(),
|
||||
a:1
|
||||
};
|
||||
// Add a toBson method to the object
|
||||
doc.toBSON = function() {
|
||||
return {b:1};
|
||||
}
|
||||
|
||||
// Serialize the data
|
||||
var serialized_data = BSON.serialize(doc, false, true);
|
||||
var deserialized_doc = BSON.deserialize(serialized_data);
|
||||
test.equal(1, deserialized_doc.b);
|
||||
test.done();
|
||||
}
|
||||
};
|
||||
|
||||
var assertArrayEqual = function(array1, array2) {
|
||||
if(array1.length != array2.length) return false;
|
||||
for(var i = 0; i < array1.length; i++) {
|
||||
if(array1[i] != array2[i]) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// String to arraybuffer
|
||||
var stringToArrayBuffer = function(string) {
|
||||
var dataBuffer = new Uint8Array(new ArrayBuffer(string.length));
|
||||
// Return the strings
|
||||
for(var i = 0; i < string.length; i++) {
|
||||
dataBuffer[i] = string.charCodeAt(i);
|
||||
}
|
||||
// Return the data buffer
|
||||
return dataBuffer;
|
||||
}
|
||||
|
||||
// String to arraybuffer
|
||||
var stringToArray = function(string) {
|
||||
var dataBuffer = new Array(string.length);
|
||||
// Return the strings
|
||||
for(var i = 0; i < string.length; i++) {
|
||||
dataBuffer[i] = string.charCodeAt(i);
|
||||
}
|
||||
// Return the data buffer
|
||||
return dataBuffer;
|
||||
}
|
||||
|
||||
var Utf8 = {
|
||||
// public method for url encoding
|
||||
encode : function (string) {
|
||||
string = string.replace(/\r\n/g,"\n");
|
||||
var utftext = "";
|
||||
|
||||
for (var n = 0; n < string.length; n++) {
|
||||
var c = string.charCodeAt(n);
|
||||
if (c < 128) {
|
||||
utftext += String.fromCharCode(c);
|
||||
} else if((c > 127) && (c < 2048)) {
|
||||
utftext += String.fromCharCode((c >> 6) | 192);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
} else {
|
||||
utftext += String.fromCharCode((c >> 12) | 224);
|
||||
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return utftext;
|
||||
},
|
||||
|
||||
// public method for url decoding
|
||||
decode : function (utftext) {
|
||||
var string = "";
|
||||
var i = 0;
|
||||
var c = c1 = c2 = 0;
|
||||
|
||||
while ( i < utftext.length ) {
|
||||
c = utftext.charCodeAt(i);
|
||||
if(c < 128) {
|
||||
string += String.fromCharCode(c);
|
||||
i++;
|
||||
} else if((c > 191) && (c < 224)) {
|
||||
c2 = utftext.charCodeAt(i+1);
|
||||
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
||||
i += 2;
|
||||
} else {
|
||||
c2 = utftext.charCodeAt(i+1);
|
||||
c3 = utftext.charCodeAt(i+2);
|
||||
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
}
|
||||
2034
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/browser/nodeunit.js
generated
vendored
Normal file
2034
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/browser/nodeunit.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
13
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/browser/suite2.js
generated
vendored
Normal file
13
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/browser/suite2.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
this.suite2 = {
|
||||
'another test': function (test) {
|
||||
setTimeout(function () {
|
||||
// lots of assertions
|
||||
test.ok(true, 'everythings ok');
|
||||
test.ok(true, 'everythings ok');
|
||||
test.ok(true, 'everythings ok');
|
||||
test.ok(true, 'everythings ok');
|
||||
test.ok(true, 'everythings ok');
|
||||
test.done();
|
||||
}, 10);
|
||||
}
|
||||
};
|
||||
7
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/browser/suite3.js
generated
vendored
Normal file
7
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/browser/suite3.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
this.suite3 = {
|
||||
'test for ie6,7,8': function (test) {
|
||||
test.deepEqual(["test"], ["test"]);
|
||||
test.notDeepEqual(["a"], ["b"]);
|
||||
test.done();
|
||||
}
|
||||
};
|
||||
30
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/browser/test.html
generated
vendored
Normal file
30
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/browser/test.html
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Example tests</title>
|
||||
<!-- Actual BSON Code -->
|
||||
<script src="../../lib/bson/binary_parser.js"></script>
|
||||
<script src="../../lib/bson/code.js"></script>
|
||||
<script src="../../lib/bson/db_ref.js"></script>
|
||||
<script src="../../lib/bson/double.js"></script>
|
||||
<script src="../../lib/bson/float_parser.js"></script>
|
||||
<script src="../../lib/bson/long.js"></script>
|
||||
<script src="../../lib/bson/max_key.js"></script>
|
||||
<script src="../../lib/bson/min_key.js"></script>
|
||||
<script src="../../lib/bson/objectid.js"></script>
|
||||
<script src="../../lib/bson/symbol.js"></script>
|
||||
<script src="../../lib/bson/timestamp.js"></script>
|
||||
<script src="../../lib/bson/bson.js"></script>
|
||||
<script src="../../lib/bson/binary.js"></script>
|
||||
|
||||
<!-- Unit tests -->
|
||||
<script src="nodeunit.js"></script>
|
||||
<script src="bson_test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
nodeunit.run({
|
||||
'bson_test': bson_test,
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
240
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/bson_array_test.js
generated
vendored
Normal file
240
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/bson_array_test.js
generated
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
var mongodb = require('../../lib/bson').pure();
|
||||
|
||||
var testCase = require('nodeunit').testCase,
|
||||
mongoO = require('../../lib/bson').pure(),
|
||||
debug = require('util').debug,
|
||||
inspect = require('util').inspect,
|
||||
Buffer = require('buffer').Buffer,
|
||||
gleak = require('../../tools/gleak'),
|
||||
fs = require('fs'),
|
||||
BSON = mongoO.BSON,
|
||||
Code = mongoO.Code,
|
||||
Binary = mongoO.Binary,
|
||||
Timestamp = mongoO.Timestamp,
|
||||
Long = mongoO.Long,
|
||||
MongoReply = mongoO.MongoReply,
|
||||
ObjectID = mongoO.ObjectID,
|
||||
Symbol = mongoO.Symbol,
|
||||
DBRef = mongoO.DBRef,
|
||||
Double = mongoO.Double,
|
||||
MinKey = mongoO.MinKey,
|
||||
MaxKey = mongoO.MaxKey,
|
||||
BinaryParser = mongoO.BinaryParser,
|
||||
utils = require('./tools/utils');
|
||||
|
||||
var BSONSE = mongodb,
|
||||
BSONDE = mongodb;
|
||||
|
||||
// for tests
|
||||
BSONDE.BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_FUNCTION = 1;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_UUID = 3;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_MD5 = 4;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
|
||||
|
||||
BSONSE.BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_FUNCTION = 1;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_UUID = 3;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_MD5 = 4;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
|
||||
|
||||
var hexStringToBinary = function(string) {
|
||||
var numberofValues = string.length / 2;
|
||||
var array = "";
|
||||
|
||||
for(var i = 0; i < numberofValues; i++) {
|
||||
array += String.fromCharCode(parseInt(string[i*2] + string[i*2 + 1], 16));
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
var assertBuffersEqual = function(test, buffer1, buffer2) {
|
||||
if(buffer1.length != buffer2.length) test.fail("Buffers do not have the same length", buffer1, buffer2);
|
||||
|
||||
for(var i = 0; i < buffer1.length; i++) {
|
||||
test.equal(buffer1[i], buffer2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Module for parsing an ISO 8601 formatted string into a Date object.
|
||||
*/
|
||||
var ISODate = function (string) {
|
||||
var match;
|
||||
|
||||
if (typeof string.getTime === "function")
|
||||
return string;
|
||||
else if (match = string.match(/^(\d{4})(-(\d{2})(-(\d{2})(T(\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|((\+|-)(\d{2}):(\d{2}))))?)?)?$/)) {
|
||||
var date = new Date();
|
||||
date.setUTCFullYear(Number(match[1]));
|
||||
date.setUTCMonth(Number(match[3]) - 1 || 0);
|
||||
date.setUTCDate(Number(match[5]) || 0);
|
||||
date.setUTCHours(Number(match[7]) || 0);
|
||||
date.setUTCMinutes(Number(match[8]) || 0);
|
||||
date.setUTCSeconds(Number(match[10]) || 0);
|
||||
date.setUTCMilliseconds(Number("." + match[12]) * 1000 || 0);
|
||||
|
||||
if (match[13] && match[13] !== "Z") {
|
||||
var h = Number(match[16]) || 0,
|
||||
m = Number(match[17]) || 0;
|
||||
|
||||
h *= 3600000;
|
||||
m *= 60000;
|
||||
|
||||
var offset = h + m;
|
||||
if (match[15] == "+")
|
||||
offset = -offset;
|
||||
|
||||
date = new Date(date.valueOf() + offset);
|
||||
}
|
||||
|
||||
return date;
|
||||
} else
|
||||
throw new Error("Invalid ISO 8601 date given.", __filename);
|
||||
};
|
||||
|
||||
var _Uint8Array = null;
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.setUp = function(callback) {
|
||||
_Uint8Array = global.Uint8Array;
|
||||
delete global['Uint8Array'];
|
||||
callback();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.tearDown = function(callback) {
|
||||
global['Uint8Array'] = _Uint8Array;
|
||||
callback();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @ignore
|
||||
// */
|
||||
// exports.shouldCorrectlyDeserializeUsingTypedArray = function(test) {
|
||||
// var motherOfAllDocuments = {
|
||||
// 'string': '客家话',
|
||||
// 'array': [1,2,3],
|
||||
// 'hash': {'a':1, 'b':2},
|
||||
// 'date': new Date(),
|
||||
// 'oid': new ObjectID(),
|
||||
// 'binary': new Binary(new Buffer("hello")),
|
||||
// 'int': 42,
|
||||
// 'float': 33.3333,
|
||||
// 'regexp': /regexp/,
|
||||
// 'boolean': true,
|
||||
// 'long': Long.fromNumber(100),
|
||||
// 'where': new Code('this.a > i', {i:1}),
|
||||
// 'dbref': new DBRef('namespace', new ObjectID(), 'integration_tests_'),
|
||||
// 'minkey': new MinKey(),
|
||||
// 'maxkey': new MaxKey()
|
||||
// }
|
||||
//
|
||||
// // Let's serialize it
|
||||
// var data = BSONSE.BSON.serialize(motherOfAllDocuments, true, true, false);
|
||||
// // Build a typed array
|
||||
// var arr = new Uint8Array(new ArrayBuffer(data.length));
|
||||
// // Iterate over all the fields and copy
|
||||
// for(var i = 0; i < data.length; i++) {
|
||||
// arr[i] = data[i]
|
||||
// }
|
||||
//
|
||||
// // Deserialize the object
|
||||
// var object = BSONDE.BSON.deserialize(arr);
|
||||
// // Asserts
|
||||
// test.equal(motherOfAllDocuments.string, object.string);
|
||||
// test.deepEqual(motherOfAllDocuments.array, object.array);
|
||||
// test.deepEqual(motherOfAllDocuments.date, object.date);
|
||||
// test.deepEqual(motherOfAllDocuments.oid.toHexString(), object.oid.toHexString());
|
||||
// test.deepEqual(motherOfAllDocuments.binary.length(), object.binary.length());
|
||||
// // Assert the values of the binary
|
||||
// for(var i = 0; i < motherOfAllDocuments.binary.length(); i++) {
|
||||
// test.equal(motherOfAllDocuments.binary.value[i], object.binary[i]);
|
||||
// }
|
||||
// test.deepEqual(motherOfAllDocuments.int, object.int);
|
||||
// test.deepEqual(motherOfAllDocuments.float, object.float);
|
||||
// test.deepEqual(motherOfAllDocuments.regexp, object.regexp);
|
||||
// test.deepEqual(motherOfAllDocuments.boolean, object.boolean);
|
||||
// test.deepEqual(motherOfAllDocuments.long.toNumber(), object.long);
|
||||
// test.deepEqual(motherOfAllDocuments.where, object.where);
|
||||
// test.deepEqual(motherOfAllDocuments.dbref.oid.toHexString(), object.dbref.oid.toHexString());
|
||||
// test.deepEqual(motherOfAllDocuments.dbref.namespace, object.dbref.namespace);
|
||||
// test.deepEqual(motherOfAllDocuments.dbref.db, object.dbref.db);
|
||||
// test.deepEqual(motherOfAllDocuments.minkey, object.minkey);
|
||||
// test.deepEqual(motherOfAllDocuments.maxkey, object.maxkey);
|
||||
// test.done();
|
||||
// }
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports.shouldCorrectlySerializeUsingTypedArray = function(test) {
|
||||
var motherOfAllDocuments = {
|
||||
'string': 'hello',
|
||||
'array': [1,2,3],
|
||||
'hash': {'a':1, 'b':2},
|
||||
'date': new Date(),
|
||||
'oid': new ObjectID(),
|
||||
'binary': new Binary(new Buffer("hello")),
|
||||
'int': 42,
|
||||
'float': 33.3333,
|
||||
'regexp': /regexp/,
|
||||
'boolean': true,
|
||||
'long': Long.fromNumber(100),
|
||||
'where': new Code('this.a > i', {i:1}),
|
||||
'dbref': new DBRef('namespace', new ObjectID(), 'integration_tests_'),
|
||||
'minkey': new MinKey(),
|
||||
'maxkey': new MaxKey()
|
||||
}
|
||||
|
||||
// Let's serialize it
|
||||
var data = BSONSE.BSON.serialize(motherOfAllDocuments, true, false, false);
|
||||
// And deserialize it again
|
||||
var object = BSONSE.BSON.deserialize(data);
|
||||
// Asserts
|
||||
test.equal(motherOfAllDocuments.string, object.string);
|
||||
test.deepEqual(motherOfAllDocuments.array, object.array);
|
||||
test.deepEqual(motherOfAllDocuments.date, object.date);
|
||||
test.deepEqual(motherOfAllDocuments.oid.toHexString(), object.oid.toHexString());
|
||||
test.deepEqual(motherOfAllDocuments.binary.length(), object.binary.length());
|
||||
// Assert the values of the binary
|
||||
for(var i = 0; i < motherOfAllDocuments.binary.length(); i++) {
|
||||
test.equal(motherOfAllDocuments.binary.value[i], object.binary[i]);
|
||||
}
|
||||
test.deepEqual(motherOfAllDocuments.int, object.int);
|
||||
test.deepEqual(motherOfAllDocuments.float, object.float);
|
||||
test.deepEqual(motherOfAllDocuments.regexp, object.regexp);
|
||||
test.deepEqual(motherOfAllDocuments.boolean, object.boolean);
|
||||
test.deepEqual(motherOfAllDocuments.long.toNumber(), object.long);
|
||||
test.deepEqual(motherOfAllDocuments.where, object.where);
|
||||
test.deepEqual(motherOfAllDocuments.dbref.oid.toHexString(), object.dbref.oid.toHexString());
|
||||
test.deepEqual(motherOfAllDocuments.dbref.namespace, object.dbref.namespace);
|
||||
test.deepEqual(motherOfAllDocuments.dbref.db, object.dbref.db);
|
||||
test.deepEqual(motherOfAllDocuments.minkey, object.minkey);
|
||||
test.deepEqual(motherOfAllDocuments.maxkey, object.maxkey);
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.noGlobalsLeaked = function(test) {
|
||||
var leaks = gleak.detectNew();
|
||||
test.equal(0, leaks.length, "global var leak detected: " + leaks.join(', '));
|
||||
test.done();
|
||||
}
|
||||
493
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/bson_parser_comparision_test.js
generated
vendored
Normal file
493
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/bson_parser_comparision_test.js
generated
vendored
Normal file
@@ -0,0 +1,493 @@
|
||||
var sys = require('util'),
|
||||
debug = require('util').debug,
|
||||
inspect = require('util').inspect,
|
||||
Buffer = require('buffer').Buffer,
|
||||
BSON = require('../../ext').BSON,
|
||||
Buffer = require('buffer').Buffer,
|
||||
BSONJS = require('../../lib/bson/bson').BSON,
|
||||
BinaryParser = require('../../lib/bson/binary_parser').BinaryParser,
|
||||
Long = require('../../lib/bson/long').Long,
|
||||
ObjectID = require('../../lib/bson/bson').ObjectID,
|
||||
Binary = require('../../lib/bson/bson').Binary,
|
||||
Code = require('../../lib/bson/bson').Code,
|
||||
DBRef = require('../../lib/bson/bson').DBRef,
|
||||
Symbol = require('../../lib/bson/bson').Symbol,
|
||||
Double = require('../../lib/bson/bson').Double,
|
||||
MaxKey = require('../../lib/bson/bson').MaxKey,
|
||||
MinKey = require('../../lib/bson/bson').MinKey,
|
||||
Timestamp = require('../../lib/bson/bson').Timestamp,
|
||||
gleak = require('../../tools/gleak'),
|
||||
assert = require('assert');
|
||||
|
||||
// Long/ObjectID/Binary/Code/DbRef/Symbol/Double/Timestamp/MinKey/MaxKey
|
||||
var bsonC = new BSON([Long, ObjectID, Binary, Code, DBRef, Symbol, Double, Timestamp, MaxKey, MinKey]);
|
||||
var bsonJS = new BSONJS([Long, ObjectID, Binary, Code, DBRef, Symbol, Double, Timestamp, MaxKey, MinKey]);
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.setUp = function(callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.tearDown = function(callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize simple edge value'] = function(test) {
|
||||
// Simple serialization and deserialization of edge value
|
||||
var doc = {doc:0x1ffffffffffffe};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
|
||||
var doc = {doc:-0x1ffffffffffffe};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly execute toJSON'] = function(test) {
|
||||
var a = Long.fromNumber(10);
|
||||
assert.equal(10, a);
|
||||
|
||||
var a = Long.fromNumber(9223372036854775807);
|
||||
assert.equal(9223372036854775807, a);
|
||||
|
||||
// Simple serialization and deserialization test for a Single String value
|
||||
var doc = {doc:'Serialize'};
|
||||
var simple_string_serialized = bsonC.serialize(doc, true, false);
|
||||
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Serialize and Deserialize nested document'] = function(test) {
|
||||
// Nested doc
|
||||
var doc = {a:{b:{c:1}}};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple integer serialization/deserialization test, including testing boundary conditions'] = function(test) {
|
||||
var doc = {doc:-1};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
|
||||
var doc = {doc:2147483648};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
|
||||
var doc = {doc:-2147483648};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple serialization and deserialization test for a Long value'] = function(test) {
|
||||
var doc = {doc:Long.fromNumber(9223372036854775807)};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize({doc:Long.fromNumber(9223372036854775807)}, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
|
||||
var doc = {doc:Long.fromNumber(-9223372036854775807)};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize({doc:Long.fromNumber(-9223372036854775807)}, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple serialization and deserialization for a Float value'] = function(test) {
|
||||
var doc = {doc:2222.3333};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
|
||||
var doc = {doc:-2222.3333};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple serialization and deserialization for a null value'] = function(test) {
|
||||
var doc = {doc:null};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple serialization and deserialization for a boolean value'] = function(test) {
|
||||
var doc = {doc:true};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple serialization and deserialization for a date value'] = function(test) {
|
||||
var date = new Date();
|
||||
var doc = {doc:date};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')), bsonC.deserialize(simple_string_serialized));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple serialization and deserialization for a boolean value'] = function(test) {
|
||||
var doc = {doc:/abcd/mi};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.equal(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')).doc.toString(), bsonC.deserialize(simple_string_serialized).doc.toString());
|
||||
|
||||
var doc = {doc:/abcd/};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc, false, true));
|
||||
assert.equal(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')).doc.toString(), bsonC.deserialize(simple_string_serialized).doc.toString());
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple serialization and deserialization for a objectId value'] = function(test) {
|
||||
var doc = {doc:new ObjectID()};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
var doc2 = {doc:ObjectID.createFromHexString(doc.doc.toHexString())};
|
||||
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize(doc2, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')).doc.toString(), bsonC.deserialize(simple_string_serialized).doc.toString());
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple serialization and deserialization for a Binary value'] = function(test) {
|
||||
var binary = new Binary();
|
||||
var string = 'binstring'
|
||||
for(var index = 0; index < string.length; index++) { binary.put(string.charAt(index)); }
|
||||
|
||||
var simple_string_serialized = bsonC.serialize({doc:binary}, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize({doc:binary}, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')).doc.value(), bsonC.deserialize(simple_string_serialized).doc.value());
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple serialization and deserialization for a Binary value of type 2'] = function(test) {
|
||||
var binary = new Binary(new Buffer('binstring'), Binary.SUBTYPE_BYTE_ARRAY);
|
||||
var simple_string_serialized = bsonC.serialize({doc:binary}, false, true);
|
||||
assert.deepEqual(simple_string_serialized, bsonJS.serialize({doc:binary}, false, true));
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized, 'binary')).doc.value(), bsonC.deserialize(simple_string_serialized).doc.value());
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple serialization and deserialization for a Code value'] = function(test) {
|
||||
var code = new Code('this.a > i', {'i': 1});
|
||||
var simple_string_serialized_2 = bsonJS.serialize({doc:code}, false, true);
|
||||
var simple_string_serialized = bsonC.serialize({doc:code}, false, true);
|
||||
|
||||
assert.deepEqual(simple_string_serialized, simple_string_serialized_2);
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized_2, 'binary')).doc.scope, bsonC.deserialize(simple_string_serialized).doc.scope);
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple serialization and deserialization for an Object'] = function(test) {
|
||||
var simple_string_serialized = bsonC.serialize({doc:{a:1, b:{c:2}}}, false, true);
|
||||
var simple_string_serialized_2 = bsonJS.serialize({doc:{a:1, b:{c:2}}}, false, true);
|
||||
assert.deepEqual(simple_string_serialized, simple_string_serialized_2)
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized_2, 'binary')).doc, bsonC.deserialize(simple_string_serialized).doc);
|
||||
|
||||
// Simple serialization and deserialization for an Array
|
||||
var simple_string_serialized = bsonC.serialize({doc:[9, 9, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1]}, false, true);
|
||||
var simple_string_serialized_2 = bsonJS.serialize({doc:[9, 9, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1]}, false, true);
|
||||
|
||||
assert.deepEqual(simple_string_serialized, simple_string_serialized_2)
|
||||
assert.deepEqual(bsonJS.deserialize(new Buffer(simple_string_serialized_2, 'binary')).doc, bsonC.deserialize(simple_string_serialized).doc);
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Simple serialization and deserialization for a DBRef'] = function(test) {
|
||||
var oid = new ObjectID()
|
||||
var oid2 = new ObjectID.createFromHexString(oid.toHexString())
|
||||
var simple_string_serialized = bsonJS.serialize({doc:new DBRef('namespace', oid2, 'integration_tests_')}, false, true);
|
||||
var simple_string_serialized_2 = bsonC.serialize({doc:new DBRef('namespace', oid, 'integration_tests_')}, false, true);
|
||||
|
||||
assert.deepEqual(simple_string_serialized, simple_string_serialized_2)
|
||||
// Ensure we have the same values for the dbref
|
||||
var object_js = bsonJS.deserialize(new Buffer(simple_string_serialized_2, 'binary'));
|
||||
var object_c = bsonC.deserialize(simple_string_serialized);
|
||||
|
||||
assert.equal(object_js.doc.namespace, object_c.doc.namespace);
|
||||
assert.equal(object_js.doc.oid.toHexString(), object_c.doc.oid.toHexString());
|
||||
assert.equal(object_js.doc.db, object_c.doc.db);
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should correctly deserialize bytes array'] = function(test) {
|
||||
// Serialized document
|
||||
var bytes = [47,0,0,0,2,110,97,109,101,0,6,0,0,0,80,97,116,116,121,0,16,97,103,101,0,34,0,0,0,7,95,105,100,0,76,100,12,23,11,30,39,8,89,0,0,1,0];
|
||||
var serialized_data = '';
|
||||
// Convert to chars
|
||||
for(var i = 0; i < bytes.length; i++) {
|
||||
serialized_data = serialized_data + BinaryParser.fromByte(bytes[i]);
|
||||
}
|
||||
var object = bsonC.deserialize(new Buffer(serialized_data, 'binary'));
|
||||
assert.equal('Patty', object.name)
|
||||
assert.equal(34, object.age)
|
||||
assert.equal('4c640c170b1e270859000001', object._id.toHexString())
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Serialize utf8'] = function(test) {
|
||||
var doc = { "name" : "本荘由利地域に洪水警報", "name1" : "öüóőúéáűíÖÜÓŐÚÉÁŰÍ", "name2" : "abcdedede"};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
var simple_string_serialized2 = bsonJS.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, simple_string_serialized2)
|
||||
|
||||
var object = bsonC.deserialize(simple_string_serialized);
|
||||
assert.equal(doc.name, object.name)
|
||||
assert.equal(doc.name1, object.name1)
|
||||
assert.equal(doc.name2, object.name2)
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Serialize object with array'] = function(test) {
|
||||
var doc = {b:[1, 2, 3]};
|
||||
var simple_string_serialized = bsonC.serialize(doc, false, true);
|
||||
var simple_string_serialized_2 = bsonJS.serialize(doc, false, true);
|
||||
assert.deepEqual(simple_string_serialized, simple_string_serialized_2)
|
||||
|
||||
var object = bsonC.deserialize(simple_string_serialized);
|
||||
assert.deepEqual(doc, object)
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Test equality of an object ID'] = function(test) {
|
||||
var object_id = new ObjectID();
|
||||
var object_id_2 = new ObjectID();
|
||||
assert.ok(object_id.equals(object_id));
|
||||
assert.ok(!(object_id.equals(object_id_2)))
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Test same serialization for Object ID'] = function(test) {
|
||||
var object_id = new ObjectID();
|
||||
var object_id2 = ObjectID.createFromHexString(object_id.toString())
|
||||
var simple_string_serialized = bsonJS.serialize({doc:object_id}, false, true);
|
||||
var simple_string_serialized_2 = bsonC.serialize({doc:object_id2}, false, true);
|
||||
|
||||
assert.equal(simple_string_serialized_2.length, simple_string_serialized.length);
|
||||
assert.deepEqual(simple_string_serialized, simple_string_serialized_2)
|
||||
var object = bsonJS.deserialize(new Buffer(simple_string_serialized_2, 'binary'));
|
||||
var object2 = bsonC.deserialize(simple_string_serialized);
|
||||
assert.equal(object.doc.id, object2.doc.id)
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Complex object serialization'] = function(test) {
|
||||
// JS Object
|
||||
var c1 = { _id: new ObjectID, comments: [], title: 'number 1' };
|
||||
var c2 = { _id: new ObjectID, comments: [], title: 'number 2' };
|
||||
var doc = {
|
||||
numbers: []
|
||||
, owners: []
|
||||
, comments: [c1, c2]
|
||||
, _id: new ObjectID
|
||||
};
|
||||
|
||||
var simple_string_serialized = bsonJS.serialize(doc, false, true);
|
||||
|
||||
// C++ Object
|
||||
var c1 = { _id: ObjectID.createFromHexString(c1._id.toHexString()), comments: [], title: 'number 1' };
|
||||
var c2 = { _id: ObjectID.createFromHexString(c2._id.toHexString()), comments: [], title: 'number 2' };
|
||||
var doc = {
|
||||
numbers: []
|
||||
, owners: []
|
||||
, comments: [c1, c2]
|
||||
, _id: ObjectID.createFromHexString(doc._id.toHexString())
|
||||
};
|
||||
|
||||
var simple_string_serialized_2 = bsonC.serialize(doc, false, true);
|
||||
|
||||
for(var i = 0; i < simple_string_serialized_2.length; i++) {
|
||||
// debug(i + "[" + simple_string_serialized_2[i] + "] = [" + simple_string_serialized[i] + "]")
|
||||
assert.equal(simple_string_serialized_2[i], simple_string_serialized[i]);
|
||||
}
|
||||
|
||||
var doc1 = bsonJS.deserialize(new Buffer(simple_string_serialized_2));
|
||||
var doc2 = bsonC.deserialize(new Buffer(simple_string_serialized_2));
|
||||
assert.equal(doc._id.id, doc1._id.id)
|
||||
assert.equal(doc._id.id, doc2._id.id)
|
||||
assert.equal(doc1._id.id, doc2._id.id)
|
||||
|
||||
var doc = {
|
||||
_id: 'testid',
|
||||
key1: { code: 'test1', time: {start:1309323402727,end:1309323402727}, x:10, y:5 },
|
||||
key2: { code: 'test1', time: {start:1309323402727,end:1309323402727}, x:10, y:5 }
|
||||
};
|
||||
|
||||
var simple_string_serialized = bsonJS.serialize(doc, false, true);
|
||||
var simple_string_serialized_2 = bsonC.serialize(doc, false, true);
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Serialize function'] = function(test) {
|
||||
var doc = {
|
||||
_id: 'testid',
|
||||
key1: function() {}
|
||||
}
|
||||
|
||||
var simple_string_serialized = bsonJS.serialize(doc, false, true, true);
|
||||
var simple_string_serialized_2 = bsonC.serialize(doc, false, true, true);
|
||||
|
||||
// Deserialize the string
|
||||
var doc1 = bsonJS.deserialize(new Buffer(simple_string_serialized_2));
|
||||
var doc2 = bsonC.deserialize(new Buffer(simple_string_serialized_2));
|
||||
assert.equal(doc1.key1.code.toString(), doc2.key1.code.toString())
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Serialize document with special operators'] = function(test) {
|
||||
var doc = {"user_id":"4e9fc8d55883d90100000003","lc_status":{"$ne":"deleted"},"owner_rating":{"$exists":false}};
|
||||
var simple_string_serialized = bsonJS.serialize(doc, false, true, true);
|
||||
var simple_string_serialized_2 = bsonC.serialize(doc, false, true, true);
|
||||
|
||||
// Should serialize to the same value
|
||||
assert.equal(simple_string_serialized_2.toString('base64'), simple_string_serialized.toString('base64'))
|
||||
var doc1 = bsonJS.deserialize(simple_string_serialized_2);
|
||||
var doc2 = bsonC.deserialize(simple_string_serialized);
|
||||
assert.deepEqual(doc1, doc2)
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Create ObjectID from hex string'] = function(test) {
|
||||
// Hex Id
|
||||
var hexId = new ObjectID().toString();
|
||||
var docJS = {_id: ObjectID.createFromHexString(hexId), 'funds.remaining': {$gte: 1.222}, 'transactions.id': {$ne: ObjectID.createFromHexString(hexId)}};
|
||||
var docC = {_id: ObjectID.createFromHexString(hexId), 'funds.remaining': {$gte: 1.222}, 'transactions.id': {$ne: ObjectID.createFromHexString(hexId)}};
|
||||
var docJSBin = bsonJS.serialize(docJS, false, true, true);
|
||||
var docCBin = bsonC.serialize(docC, false, true, true);
|
||||
assert.equal(docCBin.toString('base64'), docJSBin.toString('base64'));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Serialize big complex document'] = function(test) {
|
||||
// Complex document serialization
|
||||
var doc = {"DateTime": "Tue Nov 40 2011 17:27:55 GMT+0000 (WEST)","isActive": true,"Media": {"URL": "http://videos.sapo.pt/Tc85NsjaKjj8o5aV7Ubb"},"Title": "Lisboa fecha a ganhar 0.19%","SetPosition": 60,"Type": "videos","Thumbnail": [{"URL": "http://rd3.videos.sapo.pt/Tc85NsjaKjj8o5aV7Ubb/pic/320x240","Dimensions": {"Height": 240,"Width": 320}}],"Source": {"URL": "http://videos.sapo.pt","SetID": "1288","SourceID": "http://videos.sapo.pt/tvnet/rss2","SetURL": "http://noticias.sapo.pt/videos/tv-net_1288/","ItemID": "Tc85NsjaKjj8o5aV7Ubb","Name": "SAPO VÃdeos"},"Category": "Tec_ciencia","Description": "Lisboa fecha a ganhar 0.19%","GalleryID": new ObjectID("4eea2a634ce8573200000000"),"InternalRefs": {"RegisterDate": "Thu Dec 15 2011 17:12:51 GMT+0000 (WEST)","ChangeDate": "Thu Dec 15 2011 17:12:51 GMT+0000 (WEST)","Hash": 332279244514},"_id": new ObjectID("4eea2a96e52778160000003a")}
|
||||
var docJSBin = bsonJS.serialize(doc, false, true, true);
|
||||
var docCBin = bsonC.serialize(doc, false, true, true);
|
||||
assert.equal(docCBin.toString('base64'), docJSBin.toString('base64'));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should error out due to 24 characters but not valid hexstring for ObjectID'] = function(test) {
|
||||
try {
|
||||
var oid = new ObjectID("tttttttttttttttttttttttt");
|
||||
test.ok(false);
|
||||
} catch(err) {}
|
||||
|
||||
test.done();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports.noGlobalsLeaked = function(test) {
|
||||
var leaks = gleak.detectNew();
|
||||
test.equal(0, leaks.length, "global var leak detected: " + leaks.join(', '));
|
||||
test.done();
|
||||
}
|
||||
1694
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/bson_test.js
generated
vendored
Normal file
1694
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/bson_test.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
392
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/bson_typed_array_test.js
generated
vendored
Normal file
392
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/bson_typed_array_test.js
generated
vendored
Normal file
@@ -0,0 +1,392 @@
|
||||
var mongodb = require('../../lib/bson').pure();
|
||||
|
||||
var testCase = require('nodeunit').testCase,
|
||||
mongoO = require('../../lib/bson').pure(),
|
||||
debug = require('util').debug,
|
||||
inspect = require('util').inspect,
|
||||
Buffer = require('buffer').Buffer,
|
||||
gleak = require('../../tools/gleak'),
|
||||
fs = require('fs'),
|
||||
BSON = mongoO.BSON,
|
||||
Code = mongoO.Code,
|
||||
Binary = mongoO.Binary,
|
||||
Timestamp = mongoO.Timestamp,
|
||||
Long = mongoO.Long,
|
||||
MongoReply = mongoO.MongoReply,
|
||||
ObjectID = mongoO.ObjectID,
|
||||
Symbol = mongoO.Symbol,
|
||||
DBRef = mongoO.DBRef,
|
||||
Double = mongoO.Double,
|
||||
MinKey = mongoO.MinKey,
|
||||
MaxKey = mongoO.MaxKey,
|
||||
BinaryParser = mongoO.BinaryParser,
|
||||
utils = require('./tools/utils');
|
||||
|
||||
var BSONSE = mongodb,
|
||||
BSONDE = mongodb;
|
||||
|
||||
// for tests
|
||||
BSONDE.BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_FUNCTION = 1;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_UUID = 3;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_MD5 = 4;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
|
||||
|
||||
BSONSE.BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_FUNCTION = 1;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_UUID = 3;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_MD5 = 4;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
|
||||
|
||||
var hexStringToBinary = function(string) {
|
||||
var numberofValues = string.length / 2;
|
||||
var array = "";
|
||||
|
||||
for(var i = 0; i < numberofValues; i++) {
|
||||
array += String.fromCharCode(parseInt(string[i*2] + string[i*2 + 1], 16));
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
var assertBuffersEqual = function(test, buffer1, buffer2) {
|
||||
if(buffer1.length != buffer2.length) test.fail("Buffers do not have the same length", buffer1, buffer2);
|
||||
|
||||
for(var i = 0; i < buffer1.length; i++) {
|
||||
test.equal(buffer1[i], buffer2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Module for parsing an ISO 8601 formatted string into a Date object.
|
||||
*/
|
||||
var ISODate = function (string) {
|
||||
var match;
|
||||
|
||||
if (typeof string.getTime === "function")
|
||||
return string;
|
||||
else if (match = string.match(/^(\d{4})(-(\d{2})(-(\d{2})(T(\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|((\+|-)(\d{2}):(\d{2}))))?)?)?$/)) {
|
||||
var date = new Date();
|
||||
date.setUTCFullYear(Number(match[1]));
|
||||
date.setUTCMonth(Number(match[3]) - 1 || 0);
|
||||
date.setUTCDate(Number(match[5]) || 0);
|
||||
date.setUTCHours(Number(match[7]) || 0);
|
||||
date.setUTCMinutes(Number(match[8]) || 0);
|
||||
date.setUTCSeconds(Number(match[10]) || 0);
|
||||
date.setUTCMilliseconds(Number("." + match[12]) * 1000 || 0);
|
||||
|
||||
if (match[13] && match[13] !== "Z") {
|
||||
var h = Number(match[16]) || 0,
|
||||
m = Number(match[17]) || 0;
|
||||
|
||||
h *= 3600000;
|
||||
m *= 60000;
|
||||
|
||||
var offset = h + m;
|
||||
if (match[15] == "+")
|
||||
offset = -offset;
|
||||
|
||||
date = new Date(date.valueOf() + offset);
|
||||
}
|
||||
|
||||
return date;
|
||||
} else
|
||||
throw new Error("Invalid ISO 8601 date given.", __filename);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.setUp = function(callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.tearDown = function(callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports.shouldCorrectlyDeserializeUsingTypedArray = function(test) {
|
||||
if(typeof ArrayBuffer == 'undefined') {
|
||||
test.done();
|
||||
return;
|
||||
}
|
||||
|
||||
var motherOfAllDocuments = {
|
||||
'string': '客家话',
|
||||
'array': [1,2,3],
|
||||
'hash': {'a':1, 'b':2},
|
||||
'date': new Date(),
|
||||
'oid': new ObjectID(),
|
||||
'binary': new Binary(new Buffer("hello")),
|
||||
'int': 42,
|
||||
'float': 33.3333,
|
||||
'regexp': /regexp/,
|
||||
'boolean': true,
|
||||
'long': Long.fromNumber(100),
|
||||
'where': new Code('this.a > i', {i:1}),
|
||||
'dbref': new DBRef('namespace', new ObjectID(), 'integration_tests_'),
|
||||
'minkey': new MinKey(),
|
||||
'maxkey': new MaxKey()
|
||||
}
|
||||
|
||||
// Let's serialize it
|
||||
var data = BSONSE.BSON.serialize(motherOfAllDocuments, true, true, false);
|
||||
// Build a typed array
|
||||
var arr = new Uint8Array(new ArrayBuffer(data.length));
|
||||
// Iterate over all the fields and copy
|
||||
for(var i = 0; i < data.length; i++) {
|
||||
arr[i] = data[i]
|
||||
}
|
||||
|
||||
// Deserialize the object
|
||||
var object = BSONDE.BSON.deserialize(arr);
|
||||
// Asserts
|
||||
test.equal(motherOfAllDocuments.string, object.string);
|
||||
test.deepEqual(motherOfAllDocuments.array, object.array);
|
||||
test.deepEqual(motherOfAllDocuments.date, object.date);
|
||||
test.deepEqual(motherOfAllDocuments.oid.toHexString(), object.oid.toHexString());
|
||||
test.deepEqual(motherOfAllDocuments.binary.length(), object.binary.length());
|
||||
// Assert the values of the binary
|
||||
for(var i = 0; i < motherOfAllDocuments.binary.length(); i++) {
|
||||
test.equal(motherOfAllDocuments.binary.value[i], object.binary[i]);
|
||||
}
|
||||
test.deepEqual(motherOfAllDocuments.int, object.int);
|
||||
test.deepEqual(motherOfAllDocuments.float, object.float);
|
||||
test.deepEqual(motherOfAllDocuments.regexp, object.regexp);
|
||||
test.deepEqual(motherOfAllDocuments.boolean, object.boolean);
|
||||
test.deepEqual(motherOfAllDocuments.long.toNumber(), object.long);
|
||||
test.deepEqual(motherOfAllDocuments.where, object.where);
|
||||
test.deepEqual(motherOfAllDocuments.dbref.oid.toHexString(), object.dbref.oid.toHexString());
|
||||
test.deepEqual(motherOfAllDocuments.dbref.namespace, object.dbref.namespace);
|
||||
test.deepEqual(motherOfAllDocuments.dbref.db, object.dbref.db);
|
||||
test.deepEqual(motherOfAllDocuments.minkey, object.minkey);
|
||||
test.deepEqual(motherOfAllDocuments.maxkey, object.maxkey);
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports.shouldCorrectlySerializeUsingTypedArray = function(test) {
|
||||
if(typeof ArrayBuffer == 'undefined') {
|
||||
test.done();
|
||||
return;
|
||||
}
|
||||
|
||||
var motherOfAllDocuments = {
|
||||
'string': 'hello',
|
||||
'array': [1,2,3],
|
||||
'hash': {'a':1, 'b':2},
|
||||
'date': new Date(),
|
||||
'oid': new ObjectID(),
|
||||
'binary': new Binary(new Buffer("hello")),
|
||||
'int': 42,
|
||||
'float': 33.3333,
|
||||
'regexp': /regexp/,
|
||||
'boolean': true,
|
||||
'long': Long.fromNumber(100),
|
||||
'where': new Code('this.a > i', {i:1}),
|
||||
'dbref': new DBRef('namespace', new ObjectID(), 'integration_tests_'),
|
||||
'minkey': new MinKey(),
|
||||
'maxkey': new MaxKey()
|
||||
}
|
||||
|
||||
// Let's serialize it
|
||||
var data = BSONSE.BSON.serialize(motherOfAllDocuments, true, false, false);
|
||||
// And deserialize it again
|
||||
var object = BSONSE.BSON.deserialize(data);
|
||||
// Asserts
|
||||
test.equal(motherOfAllDocuments.string, object.string);
|
||||
test.deepEqual(motherOfAllDocuments.array, object.array);
|
||||
test.deepEqual(motherOfAllDocuments.date, object.date);
|
||||
test.deepEqual(motherOfAllDocuments.oid.toHexString(), object.oid.toHexString());
|
||||
test.deepEqual(motherOfAllDocuments.binary.length(), object.binary.length());
|
||||
// Assert the values of the binary
|
||||
for(var i = 0; i < motherOfAllDocuments.binary.length(); i++) {
|
||||
test.equal(motherOfAllDocuments.binary.value[i], object.binary[i]);
|
||||
}
|
||||
test.deepEqual(motherOfAllDocuments.int, object.int);
|
||||
test.deepEqual(motherOfAllDocuments.float, object.float);
|
||||
test.deepEqual(motherOfAllDocuments.regexp, object.regexp);
|
||||
test.deepEqual(motherOfAllDocuments.boolean, object.boolean);
|
||||
test.deepEqual(motherOfAllDocuments.long.toNumber(), object.long);
|
||||
test.deepEqual(motherOfAllDocuments.where, object.where);
|
||||
test.deepEqual(motherOfAllDocuments.dbref.oid.toHexString(), object.dbref.oid.toHexString());
|
||||
test.deepEqual(motherOfAllDocuments.dbref.namespace, object.dbref.namespace);
|
||||
test.deepEqual(motherOfAllDocuments.dbref.db, object.dbref.db);
|
||||
test.deepEqual(motherOfAllDocuments.minkey, object.minkey);
|
||||
test.deepEqual(motherOfAllDocuments.maxkey, object.maxkey);
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['exercise all the binary object constructor methods'] = function (test) {
|
||||
if(typeof ArrayBuffer == 'undefined') {
|
||||
test.done();
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct using array
|
||||
var string = 'hello world';
|
||||
// String to array
|
||||
var array = utils.stringToArrayBuffer(string);
|
||||
|
||||
// Binary from array buffer
|
||||
var binary = new Binary(utils.stringToArrayBuffer(string));
|
||||
test.ok(string.length, binary.buffer.length);
|
||||
test.ok(utils.assertArrayEqual(array, binary.buffer));
|
||||
|
||||
// Construct using number of chars
|
||||
binary = new Binary(5);
|
||||
test.ok(5, binary.buffer.length);
|
||||
|
||||
// Construct using an Array
|
||||
var binary = new Binary(utils.stringToArray(string));
|
||||
test.ok(string.length, binary.buffer.length);
|
||||
test.ok(utils.assertArrayEqual(array, binary.buffer));
|
||||
|
||||
// Construct using a string
|
||||
var binary = new Binary(string);
|
||||
test.ok(string.length, binary.buffer.length);
|
||||
test.ok(utils.assertArrayEqual(array, binary.buffer));
|
||||
test.done();
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['exercise the put binary object method for an instance when using Uint8Array'] = function (test) {
|
||||
if(typeof ArrayBuffer == 'undefined') {
|
||||
test.done();
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct using array
|
||||
var string = 'hello world';
|
||||
// String to array
|
||||
var array = utils.stringToArrayBuffer(string + 'a');
|
||||
|
||||
// Binary from array buffer
|
||||
var binary = new Binary(utils.stringToArrayBuffer(string));
|
||||
test.ok(string.length, binary.buffer.length);
|
||||
|
||||
// Write a byte to the array
|
||||
binary.put('a')
|
||||
|
||||
// Verify that the data was writtencorrectly
|
||||
test.equal(string.length + 1, binary.position);
|
||||
test.ok(utils.assertArrayEqual(array, binary.value(true)));
|
||||
test.equal('hello worlda', binary.value());
|
||||
|
||||
// Exercise a binary with lots of space in the buffer
|
||||
var binary = new Binary();
|
||||
test.ok(Binary.BUFFER_SIZE, binary.buffer.length);
|
||||
|
||||
// Write a byte to the array
|
||||
binary.put('a')
|
||||
|
||||
// Verify that the data was writtencorrectly
|
||||
test.equal(1, binary.position);
|
||||
test.ok(utils.assertArrayEqual(['a'.charCodeAt(0)], binary.value(true)));
|
||||
test.equal('a', binary.value());
|
||||
test.done();
|
||||
},
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['exercise the write binary object method for an instance when using Uint8Array'] = function (test) {
|
||||
if(typeof ArrayBuffer == 'undefined') {
|
||||
test.done();
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct using array
|
||||
var string = 'hello world';
|
||||
// Array
|
||||
var writeArrayBuffer = new Uint8Array(new ArrayBuffer(1));
|
||||
writeArrayBuffer[0] = 'a'.charCodeAt(0);
|
||||
var arrayBuffer = ['a'.charCodeAt(0)];
|
||||
|
||||
// Binary from array buffer
|
||||
var binary = new Binary(utils.stringToArrayBuffer(string));
|
||||
test.ok(string.length, binary.buffer.length);
|
||||
|
||||
// Write a string starting at end of buffer
|
||||
binary.write('a');
|
||||
test.equal('hello worlda', binary.value());
|
||||
// Write a string starting at index 0
|
||||
binary.write('a', 0);
|
||||
test.equal('aello worlda', binary.value());
|
||||
// Write a arraybuffer starting at end of buffer
|
||||
binary.write(writeArrayBuffer);
|
||||
test.equal('aello worldaa', binary.value());
|
||||
// Write a arraybuffer starting at position 5
|
||||
binary.write(writeArrayBuffer, 5);
|
||||
test.equal('aelloaworldaa', binary.value());
|
||||
// Write a array starting at end of buffer
|
||||
binary.write(arrayBuffer);
|
||||
test.equal('aelloaworldaaa', binary.value());
|
||||
// Write a array starting at position 6
|
||||
binary.write(arrayBuffer, 6);
|
||||
test.equal('aelloaaorldaaa', binary.value());
|
||||
test.done();
|
||||
},
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['exercise the read binary object method for an instance when using Uint8Array'] = function (test) {
|
||||
if(typeof ArrayBuffer == 'undefined') {
|
||||
test.done();
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct using array
|
||||
var string = 'hello world';
|
||||
var array = utils.stringToArrayBuffer(string);
|
||||
|
||||
// Binary from array buffer
|
||||
var binary = new Binary(utils.stringToArrayBuffer(string));
|
||||
test.ok(string.length, binary.buffer.length);
|
||||
|
||||
// Read the first 2 bytes
|
||||
var data = binary.read(0, 2);
|
||||
test.ok(utils.assertArrayEqual(utils.stringToArrayBuffer('he'), data));
|
||||
|
||||
// Read the entire field
|
||||
var data = binary.read(0);
|
||||
test.ok(utils.assertArrayEqual(utils.stringToArrayBuffer(string), data));
|
||||
|
||||
// Read 3 bytes
|
||||
var data = binary.read(6, 5);
|
||||
test.ok(utils.assertArrayEqual(utils.stringToArrayBuffer('world'), data));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.noGlobalsLeaked = function(test) {
|
||||
var leaks = gleak.detectNew();
|
||||
test.equal(0, leaks.length, "global var leak detected: " + leaks.join(', '));
|
||||
test.done();
|
||||
}
|
||||
BIN
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/data/test_gs_weird_bug.png
generated
vendored
Normal file
BIN
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/data/test_gs_weird_bug.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
315
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/test_full_bson.js
generated
vendored
Normal file
315
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/test_full_bson.js
generated
vendored
Normal file
@@ -0,0 +1,315 @@
|
||||
var sys = require('util'),
|
||||
fs = require('fs'),
|
||||
BSON = require('../../ext').BSON,
|
||||
Buffer = require('buffer').Buffer,
|
||||
BSONJS = require('../../lib/bson/bson').BSON,
|
||||
BinaryParser = require('../../lib/bson/binary_parser').BinaryParser,
|
||||
Long = require('../../lib/bson/long').Long,
|
||||
ObjectID = require('../../lib/bson/bson').ObjectID,
|
||||
Binary = require('../../lib/bson/bson').Binary,
|
||||
Code = require('../../lib/bson/bson').Code,
|
||||
DBRef = require('../../lib/bson/bson').DBRef,
|
||||
Symbol = require('../../lib/bson/bson').Symbol,
|
||||
Double = require('../../lib/bson/bson').Double,
|
||||
MaxKey = require('../../lib/bson/bson').MaxKey,
|
||||
MinKey = require('../../lib/bson/bson').MinKey,
|
||||
Timestamp = require('../../lib/bson/bson').Timestamp,
|
||||
gleak = require('../../tools/gleak'),
|
||||
assert = require('assert');
|
||||
|
||||
// Parsers
|
||||
var bsonC = new BSON([Long, ObjectID, Binary, Code, DBRef, Symbol, Double, Timestamp, MaxKey, MinKey]);
|
||||
var bsonJS = new BSONJS([Long, ObjectID, Binary, Code, DBRef, Symbol, Double, Timestamp, MaxKey, MinKey]);
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.setUp = function(callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.tearDown = function(callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Deserialize object'] = function(test) {
|
||||
var bytes = [95,0,0,0,2,110,115,0,42,0,0,0,105,110,116,101,103,114,97,116,105,111,110,95,116,101,115,116,115,95,46,116,101,115,116,95,105,110,100,101,120,95,105,110,102,111,114,109,97,116,105,111,110,0,8,117,110,105,113,117,101,0,0,3,107,101,121,0,12,0,0,0,16,97,0,1,0,0,0,0,2,110,97,109,101,0,4,0,0,0,97,95,49,0,0];
|
||||
var serialized_data = '';
|
||||
// Convert to chars
|
||||
for(var i = 0; i < bytes.length; i++) {
|
||||
serialized_data = serialized_data + BinaryParser.fromByte(bytes[i]);
|
||||
}
|
||||
|
||||
var object = bsonC.deserialize(serialized_data);
|
||||
assert.equal("a_1", object.name);
|
||||
assert.equal(false, object.unique);
|
||||
assert.equal(1, object.key.a);
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Deserialize object with all types'] = function(test) {
|
||||
var bytes = [26,1,0,0,7,95,105,100,0,161,190,98,75,118,169,3,0,0,3,0,0,4,97,114,114,97,121,0,26,0,0,0,16,48,0,1,0,0,0,16,49,0,2,0,0,0,16,50,0,3,0,0,0,0,2,115,116,114,105,110,103,0,6,0,0,0,104,101,108,108,111,0,3,104,97,115,104,0,19,0,0,0,16,97,0,1,0,0,0,16,98,0,2,0,0,0,0,9,100,97,116,101,0,161,190,98,75,0,0,0,0,7,111,105,100,0,161,190,98,75,90,217,18,0,0,1,0,0,5,98,105,110,97,114,121,0,7,0,0,0,2,3,0,0,0,49,50,51,16,105,110,116,0,42,0,0,0,1,102,108,111,97,116,0,223,224,11,147,169,170,64,64,11,114,101,103,101,120,112,0,102,111,111,98,97,114,0,105,0,8,98,111,111,108,101,97,110,0,1,15,119,104,101,114,101,0,25,0,0,0,12,0,0,0,116,104,105,115,46,120,32,61,61,32,51,0,5,0,0,0,0,3,100,98,114,101,102,0,37,0,0,0,2,36,114,101,102,0,5,0,0,0,116,101,115,116,0,7,36,105,100,0,161,190,98,75,2,180,1,0,0,2,0,0,0,10,110,117,108,108,0,0];
|
||||
var serialized_data = '';
|
||||
// Convert to chars
|
||||
for(var i = 0; i < bytes.length; i++) {
|
||||
serialized_data = serialized_data + BinaryParser.fromByte(bytes[i]);
|
||||
}
|
||||
|
||||
var object = bsonJS.deserialize(new Buffer(serialized_data, 'binary'));
|
||||
assert.equal("hello", object.string);
|
||||
assert.deepEqual([1, 2, 3], object.array);
|
||||
assert.equal(1, object.hash.a);
|
||||
assert.equal(2, object.hash.b);
|
||||
assert.ok(object.date != null);
|
||||
assert.ok(object.oid != null);
|
||||
assert.ok(object.binary != null);
|
||||
assert.equal(42, object.int);
|
||||
assert.equal(33.3333, object.float);
|
||||
assert.ok(object.regexp != null);
|
||||
assert.equal(true, object.boolean);
|
||||
assert.ok(object.where != null);
|
||||
assert.ok(object.dbref != null);
|
||||
assert.ok(object['null'] == null);
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Serialize and Deserialize String'] = function(test) {
|
||||
var test_string = {hello: 'world'}
|
||||
var serialized_data = bsonC.serialize(test_string)
|
||||
assert.deepEqual(test_string, bsonC.deserialize(serialized_data));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize Integer'] = function(test) {
|
||||
var test_number = {doc: 5}
|
||||
var serialized_data = bsonC.serialize(test_number)
|
||||
assert.deepEqual(test_number, bsonC.deserialize(serialized_data));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize null value'] = function(test) {
|
||||
var test_null = {doc:null}
|
||||
var serialized_data = bsonC.serialize(test_null)
|
||||
var object = bsonC.deserialize(serialized_data);
|
||||
assert.deepEqual(test_null, object);
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize undefined value'] = function(test) {
|
||||
var test_undefined = {doc:undefined}
|
||||
var serialized_data = bsonC.serialize(test_undefined)
|
||||
var object = bsonJS.deserialize(new Buffer(serialized_data, 'binary'));
|
||||
assert.equal(null, object.doc)
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize Number'] = function(test) {
|
||||
var test_number = {doc: 5.5}
|
||||
var serialized_data = bsonC.serialize(test_number)
|
||||
assert.deepEqual(test_number, bsonC.deserialize(serialized_data));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize Integer'] = function(test) {
|
||||
var test_int = {doc: 42}
|
||||
var serialized_data = bsonC.serialize(test_int)
|
||||
assert.deepEqual(test_int, bsonC.deserialize(serialized_data));
|
||||
|
||||
test_int = {doc: -5600}
|
||||
serialized_data = bsonC.serialize(test_int)
|
||||
assert.deepEqual(test_int, bsonC.deserialize(serialized_data));
|
||||
|
||||
test_int = {doc: 2147483647}
|
||||
serialized_data = bsonC.serialize(test_int)
|
||||
assert.deepEqual(test_int, bsonC.deserialize(serialized_data));
|
||||
|
||||
test_int = {doc: -2147483648}
|
||||
serialized_data = bsonC.serialize(test_int)
|
||||
assert.deepEqual(test_int, bsonC.deserialize(serialized_data));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize Object'] = function(test) {
|
||||
var doc = {doc: {age: 42, name: 'Spongebob', shoe_size: 9.5}}
|
||||
var serialized_data = bsonC.serialize(doc)
|
||||
assert.deepEqual(doc, bsonC.deserialize(serialized_data));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize Array'] = function(test) {
|
||||
var doc = {doc: [1, 2, 'a', 'b']}
|
||||
var serialized_data = bsonC.serialize(doc)
|
||||
assert.deepEqual(doc, bsonC.deserialize(serialized_data));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize Array with added on functions'] = function(test) {
|
||||
var doc = {doc: [1, 2, 'a', 'b']}
|
||||
var serialized_data = bsonC.serialize(doc)
|
||||
assert.deepEqual(doc, bsonC.deserialize(serialized_data));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize A Boolean'] = function(test) {
|
||||
var doc = {doc: true}
|
||||
var serialized_data = bsonC.serialize(doc)
|
||||
assert.deepEqual(doc, bsonC.deserialize(serialized_data));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize a Date'] = function(test) {
|
||||
var date = new Date()
|
||||
//(2009, 11, 12, 12, 00, 30)
|
||||
date.setUTCDate(12)
|
||||
date.setUTCFullYear(2009)
|
||||
date.setUTCMonth(11 - 1)
|
||||
date.setUTCHours(12)
|
||||
date.setUTCMinutes(0)
|
||||
date.setUTCSeconds(30)
|
||||
var doc = {doc: date}
|
||||
var serialized_data = bsonC.serialize(doc)
|
||||
assert.deepEqual(doc, bsonC.deserialize(serialized_data));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize Oid'] = function(test) {
|
||||
var doc = {doc: new ObjectID()}
|
||||
var serialized_data = bsonC.serialize(doc)
|
||||
assert.deepEqual(doc.doc.toHexString(), bsonC.deserialize(serialized_data).doc.toHexString())
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize Buffer'] = function(test) {
|
||||
var doc = {doc: new Buffer("123451234512345")}
|
||||
var serialized_data = bsonC.serialize(doc)
|
||||
|
||||
assert.equal("123451234512345", bsonC.deserialize(serialized_data).doc.buffer.toString('ascii'));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly encode Empty Hash'] = function(test) {
|
||||
var test_code = {}
|
||||
var serialized_data = bsonC.serialize(test_code)
|
||||
assert.deepEqual(test_code, bsonC.deserialize(serialized_data));
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize Ordered Hash'] = function(test) {
|
||||
var doc = {doc: {b:1, a:2, c:3, d:4}}
|
||||
var serialized_data = bsonC.serialize(doc)
|
||||
var decoded_hash = bsonC.deserialize(serialized_data).doc
|
||||
var keys = []
|
||||
for(var name in decoded_hash) keys.push(name)
|
||||
assert.deepEqual(['b', 'a', 'c', 'd'], keys)
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize Regular Expression'] = function(test) {
|
||||
var doc = {doc: /foobar/mi}
|
||||
var serialized_data = bsonC.serialize(doc)
|
||||
var doc2 = bsonC.deserialize(serialized_data);
|
||||
assert.equal(doc.doc.toString(), doc2.doc.toString())
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize a Binary object'] = function(test) {
|
||||
var bin = new Binary()
|
||||
var string = 'binstring'
|
||||
for(var index = 0; index < string.length; index++) {
|
||||
bin.put(string.charAt(index))
|
||||
}
|
||||
var doc = {doc: bin}
|
||||
var serialized_data = bsonC.serialize(doc)
|
||||
var deserialized_data = bsonC.deserialize(serialized_data);
|
||||
assert.equal(doc.doc.value(), deserialized_data.doc.value())
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should Correctly Serialize and Deserialize a big Binary object'] = function(test) {
|
||||
var data = fs.readFileSync("test/node/data/test_gs_weird_bug.png", 'binary');
|
||||
var bin = new Binary()
|
||||
bin.write(data)
|
||||
var doc = {doc: bin}
|
||||
var serialized_data = bsonC.serialize(doc)
|
||||
var deserialized_data = bsonC.deserialize(serialized_data);
|
||||
assert.equal(doc.doc.value(), deserialized_data.doc.value())
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports.noGlobalsLeaked = function(test) {
|
||||
var leaks = gleak.detectNew();
|
||||
test.equal(0, leaks.length, "global var leak detected: " + leaks.join(', '));
|
||||
test.done();
|
||||
}
|
||||
109
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/to_bson_test.js
generated
vendored
Normal file
109
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/to_bson_test.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
var mongodb = process.env['TEST_NATIVE'] != null ? require('../../lib/bson').native() : require('../../lib/bson').pure();
|
||||
|
||||
var testCase = require('nodeunit').testCase,
|
||||
mongoO = require('../../lib/bson').pure(),
|
||||
Buffer = require('buffer').Buffer,
|
||||
gleak = require('../../tools/gleak'),
|
||||
fs = require('fs'),
|
||||
BSON = mongoO.BSON,
|
||||
Code = mongoO.Code,
|
||||
Binary = mongoO.Binary,
|
||||
Timestamp = mongoO.Timestamp,
|
||||
Long = mongoO.Long,
|
||||
MongoReply = mongoO.MongoReply,
|
||||
ObjectID = mongoO.ObjectID,
|
||||
Symbol = mongoO.Symbol,
|
||||
DBRef = mongoO.DBRef,
|
||||
Double = mongoO.Double,
|
||||
MinKey = mongoO.MinKey,
|
||||
MaxKey = mongoO.MaxKey,
|
||||
BinaryParser = mongoO.BinaryParser;
|
||||
|
||||
var BSONSE = mongodb,
|
||||
BSONDE = mongodb;
|
||||
|
||||
// for tests
|
||||
BSONDE.BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_FUNCTION = 1;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_UUID = 3;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_MD5 = 4;
|
||||
BSONDE.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
|
||||
|
||||
BSONSE.BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_FUNCTION = 1;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_UUID = 3;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_MD5 = 4;
|
||||
BSONSE.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
|
||||
|
||||
var hexStringToBinary = function(string) {
|
||||
var numberofValues = string.length / 2;
|
||||
var array = "";
|
||||
|
||||
for(var i = 0; i < numberofValues; i++) {
|
||||
array += String.fromCharCode(parseInt(string[i*2] + string[i*2 + 1], 16));
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
var assertBuffersEqual = function(test, buffer1, buffer2) {
|
||||
if(buffer1.length != buffer2.length) test.fail("Buffers do not have the same length", buffer1, buffer2);
|
||||
|
||||
for(var i = 0; i < buffer1.length; i++) {
|
||||
test.equal(buffer1[i], buffer2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.setUp = function(callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.tearDown = function(callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
exports['Should correctly handle toBson function for an object'] = function(test) {
|
||||
// Test object
|
||||
var doc = {
|
||||
hello: new ObjectID(),
|
||||
a:1
|
||||
};
|
||||
// Add a toBson method to the object
|
||||
doc.toBSON = function() {
|
||||
return {b:1};
|
||||
}
|
||||
|
||||
// Serialize the data
|
||||
var serialized_data = new BSONSE.BSON([Long, ObjectID, Binary, Code, DBRef, Symbol, Double, Timestamp, MaxKey, MinKey]).serialize(doc, false, true);
|
||||
var deserialized_doc = new BSONDE.BSON([Long, ObjectID, Binary, Code, DBRef, Symbol, Double, Timestamp, MaxKey, MinKey]).deserialize(serialized_data);
|
||||
test.deepEqual({b:1}, deserialized_doc);
|
||||
test.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the server information for the current
|
||||
* instance of the db client
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
exports.noGlobalsLeaked = function(test) {
|
||||
var leaks = gleak.detectNew();
|
||||
test.equal(0, leaks.length, "global var leak detected: " + leaks.join(', '));
|
||||
test.done();
|
||||
}
|
||||
80
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/tools/utils.js
generated
vendored
Normal file
80
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/test/node/tools/utils.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
exports.assertArrayEqual = function(array1, array2) {
|
||||
if(array1.length != array2.length) return false;
|
||||
for(var i = 0; i < array1.length; i++) {
|
||||
if(array1[i] != array2[i]) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// String to arraybuffer
|
||||
exports.stringToArrayBuffer = function(string) {
|
||||
var dataBuffer = new Uint8Array(new ArrayBuffer(string.length));
|
||||
// Return the strings
|
||||
for(var i = 0; i < string.length; i++) {
|
||||
dataBuffer[i] = string.charCodeAt(i);
|
||||
}
|
||||
// Return the data buffer
|
||||
return dataBuffer;
|
||||
}
|
||||
|
||||
// String to arraybuffer
|
||||
exports.stringToArray = function(string) {
|
||||
var dataBuffer = new Array(string.length);
|
||||
// Return the strings
|
||||
for(var i = 0; i < string.length; i++) {
|
||||
dataBuffer[i] = string.charCodeAt(i);
|
||||
}
|
||||
// Return the data buffer
|
||||
return dataBuffer;
|
||||
}
|
||||
|
||||
exports.Utf8 = {
|
||||
// public method for url encoding
|
||||
encode : function (string) {
|
||||
string = string.replace(/\r\n/g,"\n");
|
||||
var utftext = "";
|
||||
|
||||
for (var n = 0; n < string.length; n++) {
|
||||
var c = string.charCodeAt(n);
|
||||
if (c < 128) {
|
||||
utftext += String.fromCharCode(c);
|
||||
} else if((c > 127) && (c < 2048)) {
|
||||
utftext += String.fromCharCode((c >> 6) | 192);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
} else {
|
||||
utftext += String.fromCharCode((c >> 12) | 224);
|
||||
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return utftext;
|
||||
},
|
||||
|
||||
// public method for url decoding
|
||||
decode : function (utftext) {
|
||||
var string = "";
|
||||
var i = 0;
|
||||
var c = c1 = c2 = 0;
|
||||
|
||||
while ( i < utftext.length ) {
|
||||
c = utftext.charCodeAt(i);
|
||||
if(c < 128) {
|
||||
string += String.fromCharCode(c);
|
||||
i++;
|
||||
} else if((c > 191) && (c < 224)) {
|
||||
c2 = utftext.charCodeAt(i+1);
|
||||
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
||||
i += 2;
|
||||
} else {
|
||||
c2 = utftext.charCodeAt(i+1);
|
||||
c3 = utftext.charCodeAt(i+2);
|
||||
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
}
|
||||
21
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/tools/gleak.js
generated
vendored
Normal file
21
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/tools/gleak.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
var gleak = require('gleak')();
|
||||
gleak.ignore('AssertionError');
|
||||
gleak.ignore('testFullSpec_param_found');
|
||||
gleak.ignore('events');
|
||||
gleak.ignore('Uint8Array');
|
||||
gleak.ignore('Uint8ClampedArray');
|
||||
gleak.ignore('TAP_Global_Harness');
|
||||
gleak.ignore('setImmediate');
|
||||
gleak.ignore('clearImmediate');
|
||||
|
||||
gleak.ignore('DTRACE_NET_SERVER_CONNECTION');
|
||||
gleak.ignore('DTRACE_NET_STREAM_END');
|
||||
gleak.ignore('DTRACE_NET_SOCKET_READ');
|
||||
gleak.ignore('DTRACE_NET_SOCKET_WRITE');
|
||||
gleak.ignore('DTRACE_HTTP_SERVER_REQUEST');
|
||||
gleak.ignore('DTRACE_HTTP_SERVER_RESPONSE');
|
||||
gleak.ignore('DTRACE_HTTP_CLIENT_REQUEST');
|
||||
gleak.ignore('DTRACE_HTTP_CLIENT_RESPONSE');
|
||||
|
||||
module.exports = gleak;
|
||||
20
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/tools/jasmine-1.1.0/MIT.LICENSE
generated
vendored
Normal file
20
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/tools/jasmine-1.1.0/MIT.LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2008-2011 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
190
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/tools/jasmine-1.1.0/jasmine-html.js
generated
vendored
Normal file
190
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/tools/jasmine-1.1.0/jasmine-html.js
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
jasmine.TrivialReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
this.logRunningSpecs = false;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) { el.appendChild(child); }
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var showPassed, showSkipped;
|
||||
|
||||
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
||||
this.createDom('div', { className: 'banner' },
|
||||
this.createDom('div', { className: 'logo' },
|
||||
this.createDom('span', { className: 'title' }, "Jasmine"),
|
||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||
this.createDom('div', { className: 'options' },
|
||||
"Show ",
|
||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||
)
|
||||
),
|
||||
|
||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||
);
|
||||
|
||||
this.document.body.appendChild(this.outerDiv);
|
||||
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||
this.suiteDivs[suite.id] = suiteDiv;
|
||||
var parentDiv = this.outerDiv;
|
||||
if (suite.parentSuite) {
|
||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||
}
|
||||
parentDiv.appendChild(suiteDiv);
|
||||
}
|
||||
|
||||
this.startedAt = new Date();
|
||||
|
||||
var self = this;
|
||||
showPassed.onclick = function(evt) {
|
||||
if (showPassed.checked) {
|
||||
self.outerDiv.className += ' show-passed';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||
}
|
||||
};
|
||||
|
||||
showSkipped.onclick = function(evt) {
|
||||
if (showSkipped.checked) {
|
||||
self.outerDiv.className += ' show-skipped';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var results = runner.results();
|
||||
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
||||
this.runnerDiv.setAttribute("class", className);
|
||||
//do it twice for IE
|
||||
this.runnerDiv.setAttribute("className", className);
|
||||
var specs = runner.specs();
|
||||
var specCount = 0;
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
if (this.specFilter(specs[i])) {
|
||||
specCount++;
|
||||
}
|
||||
}
|
||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
||||
|
||||
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||
var results = suite.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
||||
status = 'skipped';
|
||||
}
|
||||
this.suiteDivs[suite.id].className += " " + status;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.logRunningSpecs) {
|
||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||
title: spec.getFullName()
|
||||
}, spec.description));
|
||||
|
||||
|
||||
var resultItems = results.getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
specDiv.appendChild(messagesDiv);
|
||||
}
|
||||
|
||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
if (console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
} else {
|
||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||
return this.document.location;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
var paramMap = {};
|
||||
var params = this.getLocation().search.substring(1).split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
if (!paramMap.spec) {
|
||||
return true;
|
||||
}
|
||||
return spec.getFullName().indexOf(paramMap.spec) === 0;
|
||||
};
|
||||
166
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/tools/jasmine-1.1.0/jasmine.css
generated
vendored
Normal file
166
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/tools/jasmine-1.1.0/jasmine.css
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
body {
|
||||
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
||||
}
|
||||
|
||||
|
||||
.jasmine_reporter a:visited, .jasmine_reporter a {
|
||||
color: #303;
|
||||
}
|
||||
|
||||
.jasmine_reporter a:hover, .jasmine_reporter a:active {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.run_spec {
|
||||
float:right;
|
||||
padding-right: 5px;
|
||||
font-size: .8em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.jasmine_reporter {
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.banner {
|
||||
color: #303;
|
||||
background-color: #fef;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
float: left;
|
||||
font-size: 1.1em;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.logo .version {
|
||||
font-size: .6em;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.runner.running {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
|
||||
.options {
|
||||
text-align: right;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.suite {
|
||||
border: 1px outset gray;
|
||||
margin: 5px 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.suite .suite {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.suite.passed {
|
||||
background-color: #dfd;
|
||||
}
|
||||
|
||||
.suite.failed {
|
||||
background-color: #fdd;
|
||||
}
|
||||
|
||||
.spec {
|
||||
margin: 5px;
|
||||
padding-left: 1em;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.spec.failed, .spec.passed, .spec.skipped {
|
||||
padding-bottom: 5px;
|
||||
border: 1px solid gray;
|
||||
}
|
||||
|
||||
.spec.failed {
|
||||
background-color: #fbb;
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
.spec.passed {
|
||||
background-color: #bfb;
|
||||
border-color: green;
|
||||
}
|
||||
|
||||
.spec.skipped {
|
||||
background-color: #bbb;
|
||||
}
|
||||
|
||||
.messages {
|
||||
border-left: 1px dashed gray;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
.passed {
|
||||
background-color: #cfc;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.failed {
|
||||
background-color: #fbb;
|
||||
}
|
||||
|
||||
.skipped {
|
||||
color: #777;
|
||||
background-color: #eee;
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/*.resultMessage {*/
|
||||
/*white-space: pre;*/
|
||||
/*}*/
|
||||
|
||||
.resultMessage span.result {
|
||||
display: block;
|
||||
line-height: 2em;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.resultMessage .mismatch {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.stackTrace {
|
||||
white-space: pre;
|
||||
font-size: .8em;
|
||||
margin-left: 10px;
|
||||
max-height: 5em;
|
||||
overflow: auto;
|
||||
border: 1px inset red;
|
||||
padding: 1em;
|
||||
background: #eef;
|
||||
}
|
||||
|
||||
.finished-at {
|
||||
padding-left: 1em;
|
||||
font-size: .6em;
|
||||
}
|
||||
|
||||
.show-passed .passed,
|
||||
.show-skipped .skipped {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
#jasmine_content {
|
||||
position:fixed;
|
||||
right: 100%;
|
||||
}
|
||||
|
||||
.runner {
|
||||
border: 1px solid gray;
|
||||
display: block;
|
||||
margin: 5px 0;
|
||||
padding: 2px 0 2px 10px;
|
||||
}
|
||||
2476
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/tools/jasmine-1.1.0/jasmine.js
generated
vendored
Normal file
2476
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/tools/jasmine-1.1.0/jasmine.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/tools/jasmine-1.1.0/jasmine_favicon.png
generated
vendored
Normal file
BIN
mongoui/mongoui-master/node_modules/mongodb/node_modules/bson/tools/jasmine-1.1.0/jasmine_favicon.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 905 B |
Reference in New Issue
Block a user