mongo::BSONObj JSSleep(const mongo::BSONObj &args){ assert( args.nFields() == 1 ); assert( args.firstElement().isNumber() ); int ms = int( args.firstElement().number() ); sleepms( ms ); return undefined_; }
static BSONObj native_sleep( const mongo::BSONObj& args, void* data ) { uassert( 16259, "sleep takes a single numeric argument -- sleep(milliseconds)", args.nFields() == 1 && args.firstElement().isNumber() ); sleepmillis( static_cast<long long>( args.firstElement().number() ) ); BSONObjBuilder b; b.appendUndefined( "" ); return b.obj(); }
static BSONObj native_tostrictjson(const mongo::BSONObj& args, void* data) { uassert(40275, "tostrictjson takes a single BSON object argument, and on optional boolean argument " "for prettyPrint -- tostrictjson(obj, prettyPrint = false)", args.nFields() >= 1 && args.firstElement().isABSONObj() && (args.nFields() == 1 || (args.nFields() == 2 && args["1"].isBoolean()))); bool prettyPrint = false; if (args.nFields() == 2) { prettyPrint = args["1"].boolean(); } return BSON("" << tojson(args.firstElement().embeddedObject(), Strict, prettyPrint)); }