1 module libwasm.lodash; 2 3 import libwasm.types; 4 import libwasm.rt.memory; 5 import std.traits; 6 7 nothrow: @safe: 8 /* 9 public auto lodash(T = Any)(auto ref T init = T.init) { 10 if (!init) return Lodash(JsHandle(0), VarType.handle); 11 return Lodash(init, getVarType!T, 128); 12 }*/ 13 14 enum VarType : short { 15 handle = 1, 16 boolean = 2, 17 string_ = 3, 18 number = 4, 19 decimal = 5, 20 eval = 6, 21 Handle_string__bool = 7, // objects 22 Handle_long__bool = 8, // array 23 string_string__bool = 9, // string collection 24 string_long__bool = 10, // string array 25 long_long__bool = 11, // number array 26 } 27 28 union Param { 29 Handle handle; 30 string str; 31 long number; 32 bool boolean; 33 double decimal; 34 Callback cb; 35 } 36 37 alias NoAttributes(T) = SetFunctionAttributes!(T, "D", FunctionAttribute.none); 38 39 union Callback { 40 extern(C) bool delegate(Handle, string) iteratee_1; 41 extern(C) bool delegate(Handle, long) iteratee_2; 42 extern(C) bool delegate(string, string) iteratee_3; 43 extern(C) bool delegate(string, long) iteratee_4; 44 extern(C) bool delegate(long, long) iteratee_5; 45 extern(C) bool delegate() any; 46 } 47 48 49 VarType getVarType(T)() { 50 VarType value_type; 51 static if (is(T == Eval)) { 52 value_type = VarType.eval; 53 } 54 else static if (isSomeString!T) { 55 value_type = VarType.string_; 56 } 57 else static if (isNumeric!T) { 58 value_type = VarType.number; 59 } 60 else static if (isDelegate!T) { 61 value_type = getTypeFromCallback!T(); 62 } 63 else static if (is(T : JsHandle)) { 64 value_type = VarType.handle; 65 } 66 else static if (is(T == bool)){ 67 value_type = VarType.boolean; 68 } 69 else static if (isFloatingPoint!T) { 70 value_type = VarType.decimal; 71 } 72 return value_type; 73 } 74 75 alias CallbackType = VarType; 76 77 union InitVal { 78 string str; 79 Handle handle; 80 long number; 81 } 82 83 VarType getTypeFromCallback(T)() { 84 VarType type; 85 static if (is(NoAttributes!T == bool delegate(Handle, string))) 86 type = VarType.Handle_string__bool; 87 else static if (is (NoAttributes!T == bool delegate(Handle, long))) 88 type = VarType.Handle_long__bool; 89 else static if (is(NoAttributes!T == bool delegate(string, string))) 90 type = VarType.string_string__bool; 91 else static if (is(NoAttributes!T == bool delegate(string, long))) 92 type = VarType.string_long__bool; 93 else static if (is(NoAttributes!T == bool delegate(long, long))) 94 type = VarType.long_long__bool; 95 return type; 96 } 97 98 struct Command { 99 string func; 100 Param[5] params; 101 VarType[5] param_types; 102 short param_count; 103 @trusted: 104 void setAnyValue(T)(ref T any) { 105 size_t idx = param_count; 106 static if (is(T == Eval)) { 107 params[idx].str = any.eval_str; 108 param_types[idx] = VarType.eval; 109 } 110 else static if (isSomeString!T) { 111 //if (any.length > 64) { 112 // auto hndl = getOrCreateHandle(any); 113 // params[idx].handle = hndl; 114 // param_types[idx] = VarType.handle; 115 //} else { 116 if (any.length == 0) { 117 params[idx].str = "null"; 118 param_types[idx] = VarType.eval; 119 120 } else { 121 params[idx].str = any; 122 param_types[idx] = VarType.string_; 123 } 124 //} 125 } 126 else static if (isNumeric!T) { 127 params[idx].number = cast(long) any; 128 param_types[idx] = VarType.number; 129 } 130 else static if (is(T : JsHandle)) { 131 params[idx].handle = any.handle; 132 param_types[idx] = VarType.handle; 133 } 134 else static if (is(T == bool)){ 135 params[idx].boolean = any; 136 param_types[idx] = VarType.boolean; 137 } 138 else static if (isFloatingPoint!T) { 139 params[idx].decimal = any; 140 param_types[idx] = VarType.decimal; 141 } 142 else static if (isDelegate!T) { 143 setCallback(idx, any); 144 } else static assert(false, "Unsupported parameter supplied"); 145 param_count++; 146 } 147 148 149 void setHandleOrEval(T)(ref T values) { 150 size_t idx = param_count; 151 static if (is(T == Eval)) { 152 params[idx].str = values.eval_str; 153 param_types[idx] = VarType.eval; 154 } 155 static if (isTOrPointer!(T, JsHandle)) 156 { 157 params[idx].handle = values.handle; 158 param_types[idx] = VarType.handle; 159 } 160 else static if (isSomeString!T) { 161 params[idx].str = values; 162 param_types[idx] = VarType.eval; 163 } else static assert(false, "Unsupported type given to function (setHandleOrEval)"); 164 param_count++; 165 } 166 167 168 void setString(T)(T str) 169 { 170 size_t idx = param_count; 171 172 static if (is(T == Eval)) { 173 params[idx].str = str.eval_str; 174 param_types[idx] = VarType.eval; 175 } 176 else static if (isSomeString!T) { 177 //if (any.length > 64) { need to destroy handle, maybe this should be handled by the caller 178 // auto hndl = getOrCreateHandle(any); 179 // params[idx].handle = hndl; 180 // param_types[idx] = VarType.handle; 181 //} else { 182 if (str.length == 0) { 183 params[idx].str = "null"; 184 param_types[idx] = VarType.eval; 185 } else { 186 params[idx].str = str; 187 param_types[idx] = VarType.string_; 188 } 189 //} 190 } 191 else static if (is(T : JsHandle)) { 192 params[idx].handle = number.handle; 193 param_types[idx] = VarType.handle; 194 } else static assert(false, "Unsupported type given to function (setString)"); 195 param_count++; 196 } 197 198 void setBoolean(T)(T number) 199 { 200 size_t idx = param_count; 201 202 static if (is(T == bool)) { 203 params[idx].boolean = number.boolean; 204 param_types[idx] = VarType.boolean; 205 } 206 static if (is(T == Eval)) { 207 params[idx].str = number.eval_str; 208 param_types[idx] = VarType.eval; 209 } 210 else static if (isSomeString!T) { 211 params[idx].str = number; 212 param_types[idx] = VarType.eval; 213 } 214 else static if (isNumeric!T) { 215 params[idx].boolean = number != 0; 216 param_types[idx] = VarType.boolean; 217 } 218 else static if (is(T : JsHandle)) { 219 params[idx].handle = number.handle; 220 param_types[idx] = VarType.handle; 221 } else static assert(false, "Unsupported type given to function (setNumber)"); 222 param_count++; 223 } 224 void setNumber(T)(T number) 225 { 226 size_t idx = param_count; 227 228 static if (is(T == Eval)) { 229 params[idx].str = number.eval_str; 230 param_types[idx] = VarType.eval; 231 } 232 else static if (isSomeString!T) { 233 params[idx].str = number; 234 param_types[idx] = VarType.eval; 235 } 236 else static if (isNumeric!T) { 237 params[idx].number = cast(long) number; 238 param_types[idx] = VarType.number; 239 } 240 else static if (is(T : JsHandle)) { 241 params[idx].handle = number.handle; 242 param_types[idx] = VarType.handle; 243 } else static assert(false, "Unsupported type given to function (setNumber)"); 244 param_count++; 245 } 246 247 void setCallback(T)(size_t idx, T callback) { 248 249 static if (is(NoAttributes!T == bool delegate(Handle, string))) { 250 params[idx].cb.iteratee_1 = cast(typeof(params[idx].cb.iteratee_1))callback; 251 param_types[idx] = VarType.Handle_string__bool; 252 } 253 else static if (is (NoAttributes!T == bool delegate(Handle, long))){ 254 params[idx].cb.iteratee_2 = cast(typeof(params[idx].cb.iteratee_2))callback; 255 param_types[idx] = VarType.Handle_long__bool; 256 } 257 else static if (is(NoAttributes!T == bool delegate(string, string))) { 258 params[idx].cb.iteratee_3 = cast(typeof(params[idx].cb.iteratee_3))callback; 259 param_types[idx] = VarType.string_string__bool; 260 } 261 else static if (is(NoAttributes!T == bool delegate(string, long))) { 262 params[idx].cb.iteratee_4 = cast(typeof(params[idx].cb.iteratee_4))callback; 263 param_types[idx] = VarType.string_long__bool; 264 } 265 else static if (is(NoAttributes!T == bool delegate(long, long))) { 266 params[idx].cb.iteratee_5 = cast(typeof(params[idx].cb.iteratee_5))callback; 267 param_types[idx] = VarType.long_long__bool; 268 } else { 269 pragma(msg, (NoAttributes!T).stringof); 270 static assert(false, "Invalid callback type used as parameter"); 271 } 272 } 273 274 // Used for iteratee. Missing a lot of delegate types 275 void setCallback(T)(T callback) { 276 if (callback) { 277 size_t idx = param_count; 278 param_count++; 279 static if (is(T == Eval)) { 280 params[idx].str = callback.eval_str; 281 param_types[idx] = VarType.eval; 282 } 283 else static if (isSomeString!T) { 284 params[idx].str = callback; 285 param_types[idx] = VarType.eval; 286 } 287 else static if (is(T : JsHandle)) { // delegate registered or object 288 /* Predicates: 289 290 var users = [ 291 { 'user': 'barney', 'active': true }, 292 { 'user': 'fred', 'active': false }, 293 { 'user': 'pebbles', 'active': false } 294 ]; 295 296 // The `_.matches` iteratee shorthand. 297 _.findLastIndex(users, { 'user': 'barney', 'active': true }); 298 // => 0 299 300 // The `_.matchesProperty` iteratee shorthand. 301 _.findLastIndex(users, ['active', false]); 302 // => 2 303 304 // The `_.property` iteratee shorthand. 305 _.findLastIndex(users, 'active'); 306 // => 0 307 */ 308 params[idx].handle = any.handle; 309 param_types[idx] = VarType.handle; 310 } 311 else static if (isDelegate!T) { 312 setCallback(idx, callback); 313 } else static assert(false, "Unsupported type given to function (setCallback)"); 314 315 } 316 } 317 } 318 /++ 319 320 Creates a _. javascript compute object. Any function that 321 returns a primary type rather than Lodash will execute 322 the chaining sequence. 323 324 +/ 325 struct Lodash { 326 nothrow: 327 private: 328 329 InitVal m_initVal; 330 331 VarType m_initType = VarType.handle; 332 333 size_t m_size_est = 128; 334 335 char[] m_commands; // [{func: 'name', params:[function(){}, 2, 'str']}] 336 // [{local: 'a', value: function(){} }] 337 char* m_ptr; 338 339 // first cb is global 340 Callback m_cb; 341 CallbackType m_cbType; 342 343 extern(C) void delegate(Handle reason) m_error; 344 /* 345 // next cb are Handles 346 Handle[] m_owns; 347 Handle* m_owns_ptr; 348 */ 349 350 351 352 static struct Local(T) { 353 string local_name; 354 T value; 355 VarType value_type; 356 357 this(T)(string name, T val) { 358 local_name = name; 359 value = val; 360 value_type = getVarType!T(); 361 } 362 } 363 364 @trusted: 365 bool put(long i, bool noop = true) { 366 long u = i; 367 long maxsize = 10; 368 size_t digits = i < 0 ? 2 : 1; 369 while (digits < 20) { 370 if (u < maxsize) { 371 break; 372 } 373 maxsize *= 10; 374 digits++; 375 } 376 if (m_ptr + digits > m_commands.ptr + m_commands.length) 377 return false; 378 m_ptr += digits - 1; 379 while(u > 0) { 380 *(m_ptr--) = char('0' + u % 10); 381 u /= 10; 382 } 383 if (i < 0) *(m_ptr--) = '-'; 384 m_ptr += digits + 1; 385 return true; 386 } 387 388 bool put(bool istrue) { 389 if (istrue) return put("true"); 390 else return put("false"); 391 392 } 393 394 bool putHandle(long handle) { 395 //if (m_ptr + "nodes[]".sizeof > m_commands.ptr + m_commands.length) return false; 396 if (!put("nodes[")) return false; 397 if (!put(handle)) return false; 398 if (!put("]")) return false; 399 return true; 400 } 401 402 bool put(char c) { 403 if (m_ptr + 1 > m_commands.ptr + m_commands.length) 404 return false; 405 *(m_ptr++) = c; 406 return true; 407 } 408 409 410 bool putEval(T)(T arr) if (isSomeString!T) { 411 // starts with = 412 size_t escape_count; 413 414 foreach(el; arr) if (hasEscape(el)) escape_count++; 415 416 if (m_ptr + arr.length + 3 + escape_count > m_commands.ptr + m_commands.length) 417 return false; 418 419 *(m_ptr++) = '"'; 420 *(m_ptr++) = '='; // eval condition, escaped in strings 421 foreach (ref val; arr) { 422 if (val <= 0x1F || val == '"' || val == '\\') { 423 putEscape(val); 424 } 425 else *(m_ptr++) = val; 426 } 427 *(m_ptr++) = '"'; 428 return true; 429 } 430 431 void putEscape(char c) { 432 if (c == '\t') { *(m_ptr++) = '\\'; *(m_ptr++) = 't'; } 433 else if (c == '\b') { *(m_ptr++) = '\\'; *(m_ptr++) = 'b'; } 434 else if (c == '\n') { *(m_ptr++) = '\\'; *(m_ptr++) = 'n'; } 435 else if (c == '\r') { *(m_ptr++) = '\\'; *(m_ptr++) = 'r'; } 436 else if (c == '"') { *(m_ptr++) = '\\'; *(m_ptr++) = '"'; } 437 else if (c == '\\') { m_ptr++; *(m_ptr++) = '\\'; } 438 else { *(m_ptr++) = '?'; } 439 } 440 441 bool hasEscape(char c) { 442 if ((c <= 0x1F && c > 0xC) || (c > 0x1F && c != '"' && c != '\\')) 443 return false; 444 else if (c == '\t') return true; 445 else if (c == '\b') return true; 446 else if (c == '\n') return true; 447 else if (c == '\r') return true; 448 else if (c == '"') return true; 449 else if (c == '\\') return true; 450 else return false; // '?' 451 } 452 453 454 bool put(T)(T arr, bool to_json_string = false) if (isSomeString!T) { 455 size_t escape_count; 456 if (arr[0] == '=') { 457 if (!put('\\')) return false; 458 } 459 if (to_json_string) foreach(el; arr) if (hasEscape(el)) escape_count++; 460 461 if (m_ptr + arr.length + (to_json_string ? 2 + escape_count : 0) > m_commands.ptr + m_commands.length) 462 return false; 463 464 if (to_json_string) 465 *(m_ptr++) = '"'; 466 foreach (ref val; arr) { 467 if (to_json_string && (val <= 0x1F || val == '"' || val == '\\')) { 468 putEscape(val); 469 } 470 else *(m_ptr++) = val; 471 } 472 if (to_json_string) 473 *(m_ptr++) = '"'; 474 return true; 475 } 476 477 bool putCommand(ref Command command) { 478 // check locals 479 480 foreach (i, ref param; command.params) 481 { 482 if (i == command.param_count) break; 483 484 switch (command.param_types[i]) { 485 case VarType.Handle_string__bool: 486 //assert(m_cb.any is null, "You can only have one callback"); 487 Local!(typeof(Callback.iteratee_1)) local; 488 local.local_name = "cb"; 489 local.value = param.cb.iteratee_1; 490 local.value_type = command.param_types[i]; 491 if(!putLocal(local)) return false; 492 break; 493 case VarType.Handle_long__bool: 494 //assert(m_cb.any is null, "You can only have one callback"); 495 Local!(typeof(Callback.iteratee_2)) local; 496 local.local_name = "cb"; 497 local.value = param.cb.iteratee_2; 498 local.value_type = command.param_types[i]; 499 if(!putLocal(local)) return false; 500 break; 501 case VarType.string_string__bool: 502 //assert(m_cb.any is null, "You can only have one callback"); 503 Local!(typeof(Callback.iteratee_3)) local; 504 local.local_name = "cb"; 505 local.value = param.cb.iteratee_3; 506 local.value_type = command.param_types[i]; 507 if(!putLocal(local)) return false; 508 break; 509 case VarType.string_long__bool: 510 //assert(m_cb.any is null, "You can only have one callback"); 511 Local!(typeof(Callback.iteratee_4)) local; 512 local.local_name = "cb"; 513 local.value = param.cb.iteratee_4; 514 local.value_type = command.param_types[i]; 515 if(!putLocal(local)) return false; 516 break; 517 case VarType.long_long__bool: 518 //assert(m_cb.any is null, "You can only have one callback"); 519 Local!(typeof(Callback.iteratee_5)) local; 520 local.local_name = "cb"; 521 local.value = param.cb.iteratee_5; 522 local.value_type = command.param_types[i]; 523 if(!putLocal(local)) return false; 524 break; 525 default: 526 527 break; 528 } 529 } 530 if (!put(`{"func":`)) return false; 531 if (!put(command.func, true)) return false; 532 if (!put(`,"params":[`)) return false; 533 foreach (i, ref param; command.params) 534 { 535 if (i == command.param_count) break; 536 537 if (i > 0) if (!put(',')) return false; 538 switch (command.param_types[i]) { 539 case VarType.handle: 540 if (!putHandle(param.number)) return false; 541 break; 542 case VarType.boolean: 543 if (!put(param.boolean)) return false; 544 break; 545 case VarType.string_: 546 if (!put(param.str, true)) return false; 547 break; 548 case VarType.eval: 549 if (!putEval(param.str)) return false; 550 break; 551 case VarType.number: 552 if (!put(param.number, false)) return false; 553 break; 554 //case VarType.decimal: 555 // todo 556 // break; 557 case VarType.Handle_string__bool: 558 if (!putEval("cb")) return false; 559 break; 560 case VarType.Handle_long__bool: 561 if (!putEval("cb")) return false; 562 break; 563 case VarType.string_string__bool: 564 if (!putEval("cb")) return false; 565 break; 566 case VarType.string_long__bool: 567 if (!putEval("cb")) return false; 568 break; 569 case VarType.long_long__bool: 570 if (!putEval("cb")) return false; 571 break; 572 default: assert(false, "Command parameter type not implemented"); 573 } 574 575 } 576 if (!put("]},")) return false; 577 return true; 578 } 579 580 bool putLocal(T)(ref Local!T local) { 581 if (!put(`{"local":`)) return false; 582 if (!put(local.local_name, true)) return false; 583 if (!put(`,"value":`)) return false; 584 585 switch(local.value_type) { 586 case VarType.handle: 587 static if (isImplicitlyConvertible!(T, JsHandle)) { 588 if (!put(local.value.handle)) return false; 589 } 590 else static if (!isDelegate!T) { 591 if (!put(local.value)) return false; 592 } 593 break; 594 case VarType.string_: 595 static if (!isDelegate!T) if (!put(local.value, true)) return false; 596 break; 597 case VarType.eval: 598 static if (!isDelegate!T) if (!putEval(local.value)) return false; 599 break; 600 case VarType.boolean: 601 case VarType.number: 602 static if (!isDelegate!T) if (!put(local.value)) return false; 603 case VarType.Handle_string__bool: 604 // generate boilerplate 605 static if (is(NoAttributes!(typeof(local.value)) == bool delegate(Handle, string))) { 606 __gshared immutable cb_boilerplate_1 = `(o,s)=>{let hndl=ao(o);let str=es(0,s,null,true);return !!sifg(cbPtr)(cbCtx,str[0],str[1],hndl);}`; 607 m_cb.iteratee_1 = cast(typeof(m_cb.iteratee_1))local.value; 608 if (!putEval(cb_boilerplate_1)) return false; 609 } 610 // handler must touch Handle with any type that implements JsObject 611 break; 612 case VarType.Handle_long__bool: 613 static if (is(NoAttributes!(typeof(local.value)) == bool delegate(Handle, long))) { 614 __gshared immutable cb_boilerplate_2 = `(o,i)=>{let hndl=ao(o);return !!sifg(cbPtr)(cbCtx,BigInt(i),hndl);}`; 615 m_cb.iteratee_2 = cast(typeof(m_cb.iteratee_2))local.value; 616 if (!putEval(cb_boilerplate_2)) return false; 617 } 618 break; 619 case VarType.string_string__bool: 620 static if (is(NoAttributes!(typeof(local.value)) == bool delegate(string,string))) { 621 __gshared immutable cb_boilerplate_3 = `(s1,s2)=>{let str1=es(0,s1,null,true);let str2=es(0,s2,null,true);return !!sifg(cbPtr)(cbCtx,str2[0],str2[1],str1[0],str1[1]);}`; 622 m_cb.iteratee_3 = cast(typeof(m_cb.iteratee_3))local.value; 623 if (!putEval(cb_boilerplate_3)) return false; 624 } 625 break; 626 case VarType.string_long__bool: 627 static if (is(NoAttributes!(typeof(local.value)) == bool delegate(string, long))) { 628 __gshared immutable cb_boilerplate_4 = `(s,i)=>{let str=es(0,s,null,true);return !!sifg(cbPtr)(cbCtx,BigInt(i),str[0],str[1]);}`; 629 m_cb.iteratee_4 = cast(typeof(m_cb.iteratee_4))local.value; 630 if (!putEval(cb_boilerplate_4)) return false; 631 } 632 break; 633 case VarType.long_long__bool: 634 static if (is(NoAttributes!(typeof(local.value)) == bool delegate(long, long))) { 635 __gshared immutable cb_boilerplate_5 = `(i1,i2)=>{return !!sifg(cbPtr)(cbCtx, BigInt(i2), BigInt(i1));}`; 636 m_cb.iteratee_5 = cast(typeof(m_cb.iteratee_5))local.value; 637 if (!putEval(cb_boilerplate_5)) return false; 638 } 639 break; 640 641 default: 642 643 break;//assert(false, "Local variable type not implemented"); 644 } 645 646 if (!put("},")) return false; 647 return true; 648 649 } 650 651 /++ 652 Adds a local js variable to the compute queue. 653 Will increase memory using Allocator if need be. 654 655 Params: 656 - Local(T) Object 657 +/ 658 void tryPut(T)(ref Local!T local) { 659 char* restore = m_ptr; 660 while (!putLocal(local)) { 661 m_ptr = restore; 662 char[] alloc = cast(char[])FL_reallocate(m_commands, m_commands.length * 2); 663 m_ptr = alloc.ptr + (m_ptr - m_commands.ptr); 664 restore = m_ptr; 665 m_commands = alloc; 666 } 667 } 668 669 /++ 670 Adds a command to the compute queue. 671 Will increase memory using Allocator if need be. 672 673 Params: 674 - Command Object 675 +/ 676 void tryPut(ref Command command) { 677 char* restore = m_ptr; 678 while (!putCommand(command)) { 679 m_ptr = restore; 680 char[] alloc = cast(char[])FL_reallocate(m_commands, m_commands.length * 2); 681 m_ptr = alloc.ptr + (m_ptr - m_commands.ptr); 682 restore = m_ptr; 683 m_commands = alloc; 684 } 685 } 686 687 void setupMemory() { 688 if (!m_commands) 689 { 690 m_commands = cast(char[]) FL_allocate(m_size_est); 691 m_ptr = m_commands.ptr; 692 put('['); 693 } 694 } 695 696 @safe: 697 public: 698 699 /++ 700 Initialize the Lodash chaining with VarType 701 +/ 702 this(T)(auto ref T val, VarType init_type, int size_estimate) 703 { 704 // init with a string 705 m_initType = init_type; 706 m_size_est = size_estimate; 707 708 switch (init_type) { 709 case VarType.string_: 710 case VarType.eval: 711 static if (isImplicitlyConvertible!(T, string)) 712 m_initVal.str = val; 713 break; 714 case VarType.handle: 715 static if (isImplicitlyConvertible!(T,JsHandle)) 716 m_initVal.handle = val.handle; 717 else m_initVal.handle = val; 718 break; 719 720 case VarType.number: 721 static if (isNumeric!T) 722 m_initVal.number = cast(long)val; 723 break; 724 default: assert(false, "Not implemented"); 725 } 726 } 727 728 auto ref initialize(T)(auto ref T val, VarType init_type = VarType.handle, int size_estimate = 128) 729 { 730 // init with a string 731 m_initType = init_type; 732 m_size_est = size_estimate; 733 switch (init_type) { 734 case VarType.string_: 735 case VarType.eval: 736 static if (isImplicitlyConvertible!(T, string)) 737 m_initVal.str = val; 738 break; 739 case VarType.handle: 740 static if (isImplicitlyConvertible!(T,JsHandle)) 741 m_initVal.handle = val.handle; 742 else m_initVal.handle = val; 743 break; 744 745 case VarType.number: 746 static if (isNumeric!T) 747 m_initVal.number = cast(long)val; 748 break; 749 default: assert(false, "Not implemented"); break; 750 } 751 return this; 752 } 753 754 /++ 755 Adds a variable accessible through the javascript context 756 If it's a callback and one exists, will fail with assert failure 757 758 Params: 759 - The variable name to be defined in Javascript VM 760 - Value of the variable 761 - VarType for handling logic to define the value correctly for the Javascript VM 762 +/ 763 auto ref addLocal(T)(string var_name, auto ref T val) 764 if (!isFloatingPoint!T) //todo 765 { 766 setupMemory(); 767 768 auto ref local = Local!T(var_name, val); 769 770 assert(local.value_type != 0, "Local has no value type"); 771 772 tryPut(local); 773 774 return this; 775 } 776 777 /++ 778 Callback will be executed if javascript throws during execution 779 780 Params: 781 - The delegate which receives the error object 782 783 Returns: 784 - Unexecuted Lodash compute object with chaining capability 785 +/ 786 auto ref onError()(void delegate(Handle) errcb) @trusted { 787 m_error = cast(typeof(m_error))errcb; 788 return this; 789 } 790 791 /++ 792 Creates an array of elements split into groups the length of size. 793 If array can't be split evenly, the final chunk will be the remaining elements. 794 795 Params: 796 - [size=1] (number): The length of each chunk 797 798 Returns: 799 - Lodash chained on (Array): the new array of chunks. 800 +/ 801 auto ref chunk(T = Any)(auto ref T size = T.init) if (isNumeric!T) { 802 setupMemory(); 803 Command c = Command("chunk"); 804 if (size) c.setNumber(size); 805 tryPut(c); 806 return this; 807 } 808 809 /++ 810 Creates an array with all falsey values removed. The values false, null, 0, "", undefined, and NaN are falsey. 811 812 Returns: 813 - Lodash chained on (Array): the new array of filtered values. 814 +/ 815 auto ref compact()() { 816 setupMemory(); 817 Command c = Command("compact"); 818 tryPut(c); 819 return this; 820 } 821 822 /++ 823 Creates a new array concatenating array with any additional arrays and/or values. 824 825 Params: 826 - [values] (...*): The values to concatenate. 827 828 Returns: 829 - Lodash chained on (Array): the new concatenated array. 830 831 +/ 832 auto ref concat(ARGS...)(auto ref ARGS values) { 833 setupMemory(); 834 Command c = Command("concat"); 835 foreach(ref val; values) c.setAnyValue(val); 836 tryPut(c); 837 return this; 838 } 839 840 /++ 841 Creates an array of array values not included in the other given arrays 842 using SameValueZero for equality comparisons. 843 The order and references of result values are determined by the first array. 844 845 Params: 846 - (...Array): The values to exclude. May be an evaled string or a Handle. 847 848 Returns: 849 - Lodash chained on (Array): the new array of filtered values. 850 851 +/ 852 auto ref difference(T)(auto ref T values) { 853 setupMemory(); 854 Command c = Command("difference"); 855 c.setHandleOrEval(values); 856 tryPut(c); 857 return this; 858 } 859 860 /++ 861 This method is like _.difference except that it accepts iteratee 862 which is invoked for each element of array and values to generate the 863 criterion by which they're compared. The order and references of result 864 values are determined by the first array. The iteratee is invoked with 865 one argument: (value). 866 867 Params: 868 - [values] (...Array): The values to exclude. 869 May be an evaled string or a Handle. 870 - [iteratee=_.identity] (Function): The iteratee invoked per element. 871 872 Returns: 873 - Lodash chained on (Array): the new array of filtered values. 874 875 +/ 876 auto ref differenceBy(T, U = Any)(auto ref T values, auto ref U iteratee = U.init) 877 { 878 setupMemory(); 879 Command c = Command("differenceBy"); 880 c.setHandleOrEval(values); 881 if (iteratee) c.setCallback(iteratee); 882 tryPut(c); 883 return this; 884 } 885 886 /++ 887 This method is like _.difference except that it accepts comparator 888 which is invoked to compare elements of array to values. 889 The order and references of result values are determined by 890 the first array. The comparator is invoked with two 891 arguments: (arrVal, othVal). 892 893 Params: 894 - [values] (...Array): The values to exclude. 895 May be an evaled string or a Handle. 896 - [comparator] (Function): The comparator invoked per element. 897 898 Returns: 899 - Lodash chained on (Array): the new array of filtered values. 900 901 +/ 902 auto ref differenceWith(T, U)(auto ref T values, auto ref U comparator) 903 { 904 setupMemory(); 905 Command c = Command("differenceWith"); 906 c.setHandleOrEval(values); 907 c.setCallback(comparator); 908 tryPut(c); 909 return this; 910 } 911 912 /++ 913 Creates a slice of array with n elements dropped from the beginning. 914 915 Params: 916 - [size=1] (number): The number of elements to drop. 917 918 Returns: 919 - Lodash chained on (Array): the slice of array. 920 +/ 921 auto ref drop(T = Any)(auto ref T size = T.init) if (isNumeric!T) { 922 setupMemory(); 923 Command c = Command("drop"); 924 if (size) c.setNumber(size); 925 tryPut(c); 926 return this; 927 } 928 929 /++ 930 Creates a slice of array excluding elements dropped from the end. 931 Elements are dropped until predicate returns falsey. 932 The predicate is invoked with three arguments: (value, index, array). 933 934 Params: 935 - [predicate=_.identity] (Function): The function invoked per iteration. 936 937 Returns: 938 - Lodash chained on (Array): the slice of array. 939 +/ 940 auto ref dropRightWhile(T = Any)(auto ref T predicate = T.init) { 941 setupMemory(); 942 Command c = Command("dropRightWhile"); 943 if (predicate) c.setCallback(predicate); 944 tryPut(c); 945 return this; 946 } 947 948 /++ 949 Creates a slice of array excluding elements dropped from the beginning. 950 Elements are dropped until predicate returns falsey. 951 The predicate is invoked with three arguments: (value, index, array). 952 953 Params: 954 - [predicate=_.identity] (Function): The function invoked per iteration. 955 956 Returns: 957 - Lodash chained on (Array): the slice of array. 958 +/ 959 auto ref dropWhile(T = Any)(auto ref T predicate = T.init) { 960 setupMemory(); 961 Command c = Command("dropWhile"); 962 if (predicate) c.setCallback(predicate); 963 tryPut(c); 964 return this; 965 } 966 967 968 /++ 969 Fills elements of array with value from start up to, but not including, end. 970 971 Params: 972 - value (*): The value to fill array with. 973 - [start=0] (number): The start position. 974 - [end=array.length] (number): The end position. 975 976 Returns: 977 - Lodash chained on (Array): the filled array. 978 +/ 979 auto ref fill(T, U = Any, V = Any)(auto ref T fill_value, auto ref U start = U.init, auto ref V end = V.init) { 980 setupMemory(); 981 Command c = Command("fill"); 982 c.setAnyValue(fill_value); 983 if (start) c.setNumber(start); 984 if (end) c.setNumber(end); 985 tryPut(c); 986 return this; 987 } 988 989 990 /++ 991 This method is like _.find except that it returns the index of the first element predicate returns truthy for instead of the element itself. 992 993 Params: 994 - [predicate=_.identity] (Function): The function invoked per iteration. 995 - [fromIndex=0] (number): The index to search from. 996 997 Returns: 998 - Lodash chained on (number): the index of the found element, else -1. 999 +/ 1000 auto ref findIndex(T = Any, U = Any)(auto ref T predicate = T.init, auto ref U fromIndex = U.init) { 1001 setupMemory(); 1002 Command c = Command("findIndex"); 1003 if (predicate) c.setCallback(predicate); 1004 if (fromIndex) c.setNumber(fromIndex); 1005 tryPut(c); 1006 return this; 1007 } 1008 1009 1010 /++ 1011 This method is like _.findIndex except that it iterates over elements of collection from right to left. 1012 1013 Params: 1014 - [predicate=_.identity] (Function): The function invoked per iteration. 1015 - [fromIndex=array.length-1] (number): The index to search from. 1016 1017 Returns: 1018 - Lodash chained on (number): the index of the found element, else -1. 1019 +/ 1020 auto ref findLastIndex(T = Any, U = Any)(auto ref T predicate = T.init, auto ref U fromIndex = U.init) { 1021 setupMemory(); 1022 Command c = Command("findLastIndex"); 1023 if (predicate) c.setCallback(predicate); 1024 if (fromIndex) c.setNumber(fromIndex); 1025 tryPut(c); 1026 return this; 1027 } 1028 1029 /++ 1030 Flattens array a single level deep. 1031 1032 Returns: 1033 - Lodash chained on (Array): the new flattened array. 1034 +/ 1035 auto ref flatten()() { 1036 setupMemory(); 1037 Command c = Command("flatten"); 1038 tryPut(c); 1039 return this; 1040 } 1041 1042 /++ 1043 Recursively flattens array. 1044 1045 Returns: 1046 - Lodash chained on (Array): the new flattened array. 1047 +/ 1048 auto ref flattenDeep()() { 1049 setupMemory(); 1050 Command c = Command("flattenDeep"); 1051 tryPut(c); 1052 return this; 1053 } 1054 1055 1056 /++ 1057 Recursively flatten array up to depth levels. 1058 1059 Params: 1060 - [depth=1] (number): The maximum recursion depth. 1061 1062 Returns: 1063 - Lodash chained on (Array): the new flattened array. 1064 +/ 1065 auto ref flattenDepth(T = Any)(auto ref T depth = T.init) { 1066 setupMemory(); 1067 Command c = Command("flattenDepth"); 1068 if (depth) c.setNumber(depth); 1069 tryPut(c); 1070 return this; 1071 } 1072 1073 /++ 1074 The inverse of _.toPairs; this method returns an object composed from key-value pairs. 1075 1076 Params: 1077 - [depth=1] (number): The maximum recursion depth. 1078 1079 Returns: 1080 - Lodash chained on (Object): the new object. 1081 +/ 1082 auto ref fromPairs()() { 1083 setupMemory(); 1084 Command c = Command("fromPairs"); 1085 tryPut(c); 1086 return this; 1087 } 1088 1089 /++ 1090 Gets the first element of array. 1091 1092 Returns: 1093 - Lodash chained on (*): the first element of array. 1094 +/ 1095 auto ref head()() { 1096 setupMemory(); 1097 Command c = Command("head"); 1098 tryPut(c); 1099 return this; 1100 } 1101 1102 /++ 1103 Gets the index at which the first occurrence of value is found in 1104 array using SameValueZero for equality comparisons. If fromIndex is 1105 negative, it's used as the offset from the end of array. 1106 1107 Params: 1108 - value (*): The value to search for. 1109 - [fromIndex=0] (number): The index to search from. 1110 1111 Returns: 1112 - Lodash chained on (number): the index of the matched value, else -1. 1113 +/ 1114 auto ref indexOf(T, U = Any)(auto ref T value, auto ref U fromIndex = U.init) { 1115 setupMemory(); 1116 Command c = Command("indexOf"); 1117 c.setAnyValue(value); 1118 if (fromIndex) c.setNumber(fromIndex); 1119 tryPut(c); 1120 return this; 1121 } 1122 1123 /++ 1124 Gets all but the last element of array. 1125 1126 Returns: 1127 - Lodash chained on (Array): the slice of array. 1128 +/ 1129 auto ref initial()() { 1130 setupMemory(); 1131 Command c = Command("initial"); 1132 tryPut(c); 1133 return this; 1134 } 1135 1136 /++ 1137 Creates an array of unique values that are included in all 1138 given arrays using SameValueZero for equality comparisons. 1139 The order and references of result values are determined by the first array. 1140 1141 Returns: 1142 - Lodash chained on (Array): the new array of intersecting values. 1143 +/ 1144 auto ref intersection()() { 1145 setupMemory(); 1146 Command c = Command("intersection"); 1147 tryPut(c); 1148 return this; 1149 } 1150 1151 1152 /++ 1153 This method is like _.intersection except that it accepts iteratee 1154 which is invoked for each element of each arrays to generate the 1155 criterion by which they're compared. The order and references of 1156 result values are determined by the first array. The iteratee is 1157 invoked with one argument: (value). 1158 1159 Params: 1160 - [iteratee=_.identity] (Function): The iteratee invoked per element. 1161 1162 Returns: 1163 - Lodash chained on (Array): the new array of intersecting values. 1164 1165 +/ 1166 auto ref intersectionBy(T = Any)(auto ref T iteratee = T.init) 1167 { 1168 setupMemory(); 1169 Command c = Command("intersectionBy"); 1170 if (iteratee) c.setCallback(iteratee); 1171 tryPut(c); 1172 return this; 1173 } 1174 1175 1176 /++ 1177 This method is like _.intersection except that it accepts comparator 1178 which is invoked to compare elements of arrays. The order and references 1179 of result values are determined by the first array. 1180 The comparator is invoked with two arguments: (arrVal, othVal). 1181 1182 Params: 1183 - [comparator] (Function): The comparator invoked per element. 1184 1185 Returns: 1186 - Lodash chained on (Array): the new array of intersecting values. 1187 1188 +/ 1189 auto ref intersectionWith(T)(auto ref T comparator) 1190 { 1191 setupMemory(); 1192 Command c = Command("intersectionWith"); 1193 if (comparator) c.setCallback(comparator); 1194 tryPut(c); 1195 return this; 1196 } 1197 1198 /++ 1199 Converts all elements in array into a string separated by separator. 1200 1201 Params: 1202 - [separator=','] (string): The element separator. 1203 1204 Returns: 1205 - Lodash chained on (string): the joined string. 1206 1207 +/ 1208 auto ref join(T)(auto ref T separator) 1209 { 1210 setupMemory(); 1211 Command c = Command("join"); 1212 if (separator) c.setString(separator); 1213 tryPut(c); 1214 return this; 1215 } 1216 1217 1218 /++ 1219 Gets the last element of array. 1220 1221 Returns: 1222 - Lodash chained on (*): the last element of array. 1223 +/ 1224 auto ref last()() { 1225 setupMemory(); 1226 Command c = Command("last"); 1227 tryPut(c); 1228 return this; 1229 } 1230 1231 /++ 1232 This method is like _.indexOf except that it iterates over elements 1233 of array from right to left. 1234 1235 Params: 1236 - value (*): The value to search for. 1237 - [fromIndex=array.length-1] (number): The index to search from. 1238 1239 Returns: 1240 - Lodash chained on (number): the index of the matched value, else -1. 1241 +/ 1242 auto ref lastIndexOf(T, U = Any)(auto ref T value, auto ref U fromIndex = U.init) { 1243 setupMemory(); 1244 Command c = Command("lastIndexOf"); 1245 c.setAnyValue(value); 1246 if (fromIndex) c.setNumber(fromIndex); 1247 tryPut(c); 1248 return this; 1249 } 1250 1251 /++ 1252 Gets the element at index n of array. If n is negative, the nth element 1253 from the end is returned. 1254 1255 Params: 1256 - [n=0] (number): The index of the element to return. 1257 1258 Returns: 1259 - Lodash chained on (*): the nth element of array. 1260 +/ 1261 auto ref nth(T = Any)(auto ref T n = T.init) { 1262 setupMemory(); 1263 Command c = Command("nth"); 1264 if (n) c.setNumber(n); 1265 tryPut(c); 1266 return this; 1267 } 1268 1269 1270 /++ 1271 Removes all given values from array using SameValueZero for equality 1272 comparisons. 1273 1274 Note: Unlike _.without, this method mutates array. Use _.remove to 1275 remove elements from an array by predicate. 1276 1277 Params: 1278 - [values] (...*): The values to remove. 1279 1280 Returns: 1281 - Lodash chained on (Array): array. 1282 +/ 1283 auto ref pull(ARGS...)(auto ref ARGS values) { 1284 setupMemory(); 1285 Command c = Command("pull"); 1286 foreach(ref val; values) c.setAnyValue(val); 1287 tryPut(c); 1288 return this; 1289 } 1290 1291 1292 /++ 1293 This method is like _.pull except that it accepts an array of values to 1294 remove. 1295 1296 Note: Unlike _.difference, this method mutates array. 1297 1298 Params: 1299 - values (Array): The values to remove. May be a handle to an array or evaled string 1300 1301 Returns: 1302 - Lodash chained on (Array): array. 1303 +/ 1304 auto ref pullAll(T)(auto ref T values) { 1305 setupMemory(); 1306 Command c = Command("pullAll"); 1307 c.setHandleOrEval(values); 1308 tryPut(c); 1309 return this; 1310 } 1311 1312 1313 /++ 1314 This method is like _.pullAll except that it accepts iteratee which is 1315 invoked for each element of array and values to generate the criterion 1316 by which they're compared. The iteratee is invoked with one argument: 1317 (value). 1318 1319 Note: Unlike _.differenceBy, this method mutates array. 1320 1321 Params: 1322 - values (Array): The values to remove. May be a handle to an array or evaled string 1323 - [iteratee=_.identity] (Function): The iteratee invoked per element. 1324 1325 Returns: 1326 - Lodash chained on (Array): array. 1327 +/ 1328 auto ref pullAllBy(T, U = Any)(auto ref T values, auto ref U iteratee = U.init) { 1329 setupMemory(); 1330 Command c = Command("pullAllBy"); 1331 c.setHandleOrEval(values); 1332 if (iteratee) c.setCallback(iteratee); 1333 tryPut(c); 1334 return this; 1335 } 1336 1337 1338 /++ 1339 This method is like _.pullAll except that it accepts iteratee which is 1340 invoked for each element of array and values to generate the criterion 1341 by which they're compared. The iteratee is invoked with one argument: 1342 (value). 1343 1344 Note: Unlike _.differenceWith, this method mutates array. 1345 1346 Params: 1347 - values (Array): The values to remove. May be a handle to an array or evaled string 1348 - [iteratee=_.identity] (Function): The iteratee invoked per element. 1349 1350 Returns: 1351 - Lodash chained on (Array): array. 1352 +/ 1353 auto ref pullAllWith(T, U = Any)(auto ref T values, auto ref U iteratee = U.init) { 1354 setupMemory(); 1355 Command c = Command("pullAllWith"); 1356 c.setHandleOrEval(values); 1357 if (iteratee) c.setCallback(iteratee); 1358 tryPut(c); 1359 return this; 1360 } 1361 1362 /++ 1363 Removes elements from array corresponding to indexes and returns an 1364 array of removed elements. 1365 1366 Note: Unlike _.at, this method mutates array. 1367 1368 Params: 1369 - [indexes] (...(number|number[])): The indexes of elements to remove. 1370 1371 Returns: 1372 - Lodash chained on (Array): the new array of removed elements. 1373 +/ 1374 auto ref pullAt(ARGS...)(auto ref ARGS values) { 1375 setupMemory(); 1376 Command c = Command("pullAt"); 1377 foreach(ref val; values) c.setNumber(val); // could be a JsHandle to an array too 1378 tryPut(c); 1379 return this; 1380 } 1381 1382 /++ 1383 Removes all elements from array that predicate returns truthy for and 1384 returns an array of the removed elements. The predicate is invoked with 1385 three arguments: (value, index, array). 1386 1387 Note: Unlike _.filter, this method mutates array. Use _.pull to pull 1388 elements from an array by value. 1389 1390 Params: 1391 - [predicate=_.identity] (Function): The function invoked per iteration. 1392 1393 Returns: 1394 - Lodash chained on (Array): the new array of removed elements. 1395 +/ 1396 auto ref remove(T = Any)(auto ref T predicate = T.init) { 1397 setupMemory(); 1398 Command c = Command("remove"); 1399 if (predicate) c.setCallback(predicate); 1400 tryPut(c); 1401 return this; 1402 } 1403 1404 /++ 1405 Reverses array so that the first element becomes the last, the second 1406 element becomes the second to last, and so on. 1407 1408 Note: This method mutates array and is based on Array#reverse. 1409 1410 Returns: 1411 - Lodash chained on (Array): array. 1412 +/ 1413 auto ref reverse()() { 1414 setupMemory(); 1415 Command c = Command("reverse"); 1416 tryPut(c); 1417 return this; 1418 } 1419 1420 /++ 1421 Fills elements of array with value from start up to, but not including, end. 1422 1423 Params: 1424 - [start=0] (number): The start position. 1425 - [end=array.length] (number): The end position. 1426 1427 Returns: 1428 - Lodash chained on (Array): the slice of array. 1429 +/ 1430 auto ref slice(T = Any, U = Any)(auto ref T start = T.init, auto ref U end = U.init) { 1431 setupMemory(); 1432 Command c = Command("slice"); 1433 if (start) c.setNumber(start); 1434 if (end) c.setNumber(end); 1435 tryPut(c); 1436 return this; 1437 } 1438 1439 /++ 1440 Uses a binary search to determine the lowest index at which value 1441 should be inserted into array in order to maintain its sort order. 1442 1443 Params: 1444 - value (*): The value to evaluate. 1445 1446 Returns: 1447 - Lodash chained on (number): the index at which value should be inserted into array. 1448 1449 +/ 1450 auto ref sortedIndex(T)(auto ref T value) { 1451 setupMemory(); 1452 Command c = Command("sortedIndex"); 1453 c.setAnyValue(value); 1454 tryPut(c); 1455 return this; 1456 } 1457 1458 1459 /++ 1460 This method is like _.sortedIndex except that it accepts iteratee which is 1461 invoked for value and each element of array to compute their sort ranking. 1462 The iteratee is invoked with one argument: (value). 1463 1464 Params: 1465 - value (*): The value to evaluate. 1466 - [iteratee=_.identity] (Function): The iteratee invoked per element. 1467 1468 Returns: 1469 - Lodash chained on (number): the index at which value should be inserted into array. 1470 1471 +/ 1472 auto ref sortedIndexBy(T, U)(auto ref T value, auto ref U iteratee = U.init) { 1473 setupMemory(); 1474 Command c = Command("sortedIndexBy"); 1475 c.setAnyValue(value); 1476 if (iteratee) c.setCallback(iteratee); 1477 tryPut(c); 1478 return this; 1479 } 1480 1481 /++ 1482 This method is like _.indexOf except that it performs a binary search on a sorted array. 1483 1484 Params: 1485 - value (*): The value to search for. 1486 1487 Returns: 1488 - Lodash chained on (number): the index of the matched value, else -1. 1489 1490 +/ 1491 auto ref sortedIndexOf(T)(auto ref T value) { 1492 setupMemory(); 1493 Command c = Command("sortedIndexOf"); 1494 c.setAnyValue(value); 1495 tryPut(c); 1496 return this; 1497 } 1498 1499 /++ 1500 This method is like _.sortedIndex except that it returns the highest index 1501 at which value should be inserted into array in order to maintain its 1502 sort order. 1503 1504 Params: 1505 - value (*): The value to evaluate. 1506 1507 Returns: 1508 - Lodash chained on (number): the index at which value should be inserted into array. 1509 1510 +/ 1511 auto ref sortedLastIndex(T)(auto ref T value) { 1512 setupMemory(); 1513 Command c = Command("sortedLastIndex"); 1514 c.setAnyValue(value); 1515 tryPut(c); 1516 return this; 1517 } 1518 1519 /++ 1520 This method is like _.sortedLastIndex except that it accepts iteratee 1521 which is invoked for value and each element of array to compute their 1522 sort ranking. The iteratee is invoked with one argument: (value). 1523 1524 Params: 1525 - value (*): The value to evaluate. 1526 - [iteratee=_.identity] (Function): The iteratee invoked per element. 1527 1528 Returns: 1529 - Lodash chained on (number): the index at which value should be inserted into array. 1530 1531 +/ 1532 auto ref sortedLastIndexBy(T, U)(auto ref T value, auto ref U iteratee = U.init) { 1533 setupMemory(); 1534 Command c = Command("sortedLastIndexBy"); 1535 c.setAnyValue(value); 1536 if (iteratee) c.setCallback(iteratee); 1537 tryPut(c); 1538 return this; 1539 } 1540 1541 1542 /++ 1543 This method is like _.lastIndexOf except that it performs a binary search on a sorted array. 1544 1545 Params: 1546 - value (*): The value to search for. 1547 1548 Returns: 1549 - Lodash chained on (number): the index of the matched value, else -1. 1550 1551 +/ 1552 auto ref sortedLastIndexOf(T)(auto ref T value) { 1553 setupMemory(); 1554 Command c = Command("sortedLastIndexOf"); 1555 c.setAnyValue(value); 1556 tryPut(c); 1557 return this; 1558 } 1559 1560 /++ 1561 This method is like _.uniq except that it's designed and optimized for sorted arrays. 1562 1563 Returns: 1564 - Lodash chained on (Array): the new duplicate free array. 1565 1566 +/ 1567 auto ref sortedUniq()() { 1568 setupMemory(); 1569 Command c = Command("sortedUniq"); 1570 tryPut(c); 1571 return this; 1572 } 1573 1574 /++ 1575 This method is like _.uniqBy except that it's designed and optimized for sorted arrays. 1576 1577 Params: 1578 - [iteratee] (Function): The iteratee invoked per element. 1579 1580 Returns: 1581 - Lodash chained on (Array): the new duplicate free array. 1582 1583 +/ 1584 auto ref sortedUniqBy(T)(auto ref T iteratee) { 1585 setupMemory(); 1586 Command c = Command("sortedUniqBy"); 1587 c.setCallback(iteratee); 1588 tryPut(c); 1589 return this; 1590 } 1591 1592 1593 /++ 1594 Gets all but the first element of array. 1595 1596 Returns: 1597 - Lodash chained on (Array): the slice of array. 1598 1599 +/ 1600 auto ref tail()() { 1601 setupMemory(); 1602 Command c = Command("tail"); 1603 tryPut(c); 1604 return this; 1605 } 1606 1607 /++ 1608 Creates a slice of array with n elements taken from the beginning. 1609 1610 Params: 1611 - [n=1] (number): The number of elements to take. 1612 1613 Returns: 1614 - Lodash chained on (Array): the slice of array. 1615 1616 +/ 1617 auto ref take(T = Any)(auto ref T n = T.init) { 1618 setupMemory(); 1619 Command c = Command("take"); 1620 if (n) c.setNumber(n); 1621 tryPut(c); 1622 return this; 1623 } 1624 1625 /++ 1626 Creates a slice of array with n elements taken from the end. 1627 1628 Params: 1629 - [n=1] (number): The number of elements to take. 1630 1631 Returns: 1632 - Lodash chained on (Array): the slice of array. 1633 1634 +/ 1635 auto ref takeRight(T = Any)(auto ref T n = T.init) { 1636 setupMemory(); 1637 Command c = Command("takeRight"); 1638 if (n) c.setNumber(n); 1639 tryPut(c); 1640 return this; 1641 } 1642 1643 /++ 1644 Creates a slice of array with elements taken from the end. 1645 Elements are taken until predicate returns falsey. 1646 The predicate is invoked with three arguments: (value, index, array). 1647 1648 Params: 1649 - [predicate=_.identity] (Function): The function invoked per iteration. 1650 1651 Returns: 1652 - Lodash chained on (Array): the slice of array. 1653 1654 +/ 1655 auto ref takeRightWhile(T = Any)(auto ref T predicate = T.init) { 1656 setupMemory(); 1657 Command c = Command("takeRightWhile"); 1658 if (predicate) c.setCallback(predicate); 1659 tryPut(c); 1660 return this; 1661 } 1662 1663 /++ 1664 Creates a slice of array with elements taken from the beginning. 1665 Elements are taken until predicate returns falsey. 1666 The predicate is invoked with three arguments: (value, index, array). 1667 1668 Params: 1669 - [predicate=_.identity] (Function): The function invoked per iteration. 1670 1671 Returns: 1672 - Lodash chained on (Array): the slice of array. 1673 1674 +/ 1675 auto ref takeWhile(T = Any)(auto ref T predicate = T.init) { 1676 setupMemory(); 1677 Command c = Command("takeWhile"); 1678 if (predicate) c.setCallback(predicate); 1679 tryPut(c); 1680 return this; 1681 } 1682 1683 /++ 1684 Creates an array of unique values, in order, from all given arrays using 1685 SameValueZero for equality comparisons. 1686 1687 Params: 1688 - [arrays] (...Array): The arrays to inspect. 1689 1690 Returns: 1691 - Lodash chained on (Array): the new array of combined values. 1692 +/ 1693 auto ref union_(ARGS...)(auto ref ARGS values) { 1694 setupMemory(); 1695 Command c = Command("union"); 1696 foreach(ref val; values) c.setHandleOrEval(val); // could be a JsHandle to an array too 1697 tryPut(c); 1698 return this; 1699 } 1700 1701 1702 /++ 1703 This method is like _.union except that it accepts iteratee which is 1704 invoked for each element of each arrays to generate the criterion by 1705 which uniqueness is computed. Result values are chosen from the first 1706 array in which the value occurs. The iteratee is invoked with one argument: 1707 (value). 1708 1709 Params: 1710 - [arrays] (...Array): The arrays to inspect. 1711 - [iteratee=_.identity] (Function): The iteratee invoked per element. 1712 1713 Returns: 1714 - Lodash chained on (Array): the new array of combined values. 1715 +/ 1716 auto ref unionBy(T)(auto ref T values, auto ref U iteratee = U.init) { 1717 setupMemory(); 1718 Command c = Command("unionBy"); 1719 c.setHandleOrEval(values); 1720 if (iteratee) c.setHandleOrEval(iteratee); 1721 tryPut(c); 1722 return this; 1723 } 1724 1725 /++ 1726 This method is like _.union except that it accepts comparator which is 1727 invoked to compare elements of arrays. Result values are chosen from 1728 the first array in which the value occurs. The comparator is invoked 1729 with two arguments: (arrVal, othVal). 1730 1731 Params: 1732 - [arrays] (...Array): The arrays to inspect. 1733 - [comparator] (Function): The comparator invoked per element. 1734 1735 Returns: 1736 - Lodash chained on (Array): the new array of combined values. 1737 +/ 1738 auto ref unionWith(T)(auto ref T values, auto ref U comparator = U.init) { 1739 setupMemory(); 1740 Command c = Command("unionWith"); 1741 c.setHandleOrEval(values); 1742 if (comparator) c.setHandleOrEval(comparator); 1743 tryPut(c); 1744 return this; 1745 } 1746 1747 /++ 1748 Creates a duplicate-free version of an array, using SameValueZero for 1749 equality comparisons, in which only the first occurrence of each element 1750 is kept. The order of result values is determined by the order they occur 1751 in the array. 1752 1753 Returns: 1754 - Lodash chained on (Array): the new duplicate free array. 1755 1756 +/ 1757 auto ref uniq()() { 1758 setupMemory(); 1759 Command c = Command("uniq"); 1760 tryPut(c); 1761 return this; 1762 } 1763 1764 /++ 1765 This method is like _.uniq except that it accepts iteratee which is 1766 invoked for each element in array to generate the criterion by which 1767 uniqueness is computed. The order of result values is determined by 1768 the order they occur in the array. The iteratee is invoked with one 1769 argument: (value). 1770 1771 Params: 1772 - [iteratee=_.identity] (Function): The iteratee invoked per element. 1773 1774 Returns: 1775 - Lodash chained on (Array): the new duplicate free array. 1776 1777 +/ 1778 auto ref uniqBy(T = Any)(auto ref T iteratee = T.init) { 1779 setupMemory(); 1780 Command c = Command("uniqBy"); 1781 if (iteratee) c.setCallback(iteratee); 1782 tryPut(c); 1783 return this; 1784 } 1785 1786 /++ 1787 This method is like _.uniq except that it accepts comparator which is 1788 invoked to compare elements of array. The order of result values is 1789 determined by the order they occur in the array.The comparator is 1790 invoked with two arguments: (arrVal, othVal). 1791 1792 Params: 1793 - [comparator] (Function): The comparator invoked per element. 1794 1795 Returns: 1796 - Lodash chained on (Array): the new duplicate free array. 1797 1798 +/ 1799 auto ref uniqWith(T)(auto ref T comparator = T.init) { 1800 setupMemory(); 1801 Command c = Command("uniqWith"); 1802 c.setCallback(comparator); 1803 tryPut(c); 1804 return this; 1805 } 1806 1807 1808 /++ 1809 This method is like _.zip except that it accepts an array of grouped 1810 elements and creates an array regrouping the elements to their pre-zip 1811 configuration. 1812 1813 Returns: 1814 - Lodash chained on (Array): the new array of regrouped elements. 1815 1816 +/ 1817 auto ref unzip()() { 1818 setupMemory(); 1819 Command c = Command("unzip"); 1820 tryPut(c); 1821 return this; 1822 } 1823 1824 /++ 1825 This method is like _.unzip except that it accepts iteratee to specify 1826 how regrouped values should be combined. The iteratee is invoked with 1827 the elements of each group: (...group). 1828 1829 Params: 1830 - [iteratee=_.identity] (Function): The function to combine regrouped values. 1831 1832 Returns: 1833 - Lodash chained on (Array): the new array of regrouped elements. 1834 1835 +/ 1836 auto ref unzipWith(T)(auto ref T iteratee = T.init) { 1837 setupMemory(); 1838 Command c = Command("unzipWith"); 1839 c.setCallback(iteratee); 1840 tryPut(c); 1841 return this; 1842 } 1843 1844 /++ 1845 This method is like _.unzip except that it accepts iteratee to specify 1846 how regrouped values should be combined. The iteratee is invoked with 1847 the elements of each group: (...group). 1848 1849 Params: 1850 - [values] (...*): The values to exclude. 1851 1852 Returns: 1853 - Lodash chained on (Array): the new array of filtered values. 1854 1855 +/ 1856 auto ref without(ARGS...)(auto ref ARGS values) { 1857 setupMemory(); 1858 Command c = Command("without"); 1859 foreach(ref val; values) c.setAnyValue(val); 1860 tryPut(c); 1861 return this; 1862 } 1863 1864 /++ 1865 Creates an array of unique values that is the symmetric difference of 1866 the given arrays. The order of result values is determined by the order 1867 they occur in the arrays. 1868 1869 Params: 1870 - [arrays] (...Array): The arrays to inspect. 1871 1872 Returns: 1873 - Lodash chained on (Array): the new array of filtered values. 1874 1875 +/ 1876 auto ref xor(ARGS...)(auto ref ARGS arrays) { 1877 setupMemory(); 1878 Command c = Command("xor"); 1879 foreach(ref val; arrays) c.setHandleOrEval(val); 1880 tryPut(c); 1881 return this; 1882 } 1883 1884 /++ 1885 This method is like _.xor except that it accepts iteratee which is 1886 invoked for each element of each arrays to generate the criterion by 1887 which by which they're compared. The order of result values is 1888 determined by the order they occur in the arrays. The iteratee is 1889 invoked with one argument: (value). 1890 1891 Params: 1892 - [arrays] (...Array): The arrays to inspect. 1893 - [iteratee=_.identity] (Function): The iteratee invoked per element. 1894 1895 Returns: 1896 - Lodash chained on (Array): the new array of filtered values. 1897 1898 +/ 1899 auto ref xorBy(T, U = Any)(auto ref T values, auto ref U iteratee = U.init) { 1900 setupMemory(); 1901 Command c = Command("xorBy"); 1902 c.setHandleOrEval(values); 1903 if (iteratee) c.setCallback(iteratee); 1904 tryPut(c); 1905 return this; 1906 } 1907 1908 1909 /++ 1910 This method is like _.xor except that it accepts comparator which is 1911 invoked to compare elements of arrays. The order of result values is 1912 determined by the order they occur in the arrays. The comparator is 1913 invoked with two arguments: (arrVal, othVal). 1914 1915 Params: 1916 - [arrays] (...Array): The arrays to inspect. 1917 - [comparator] (Function): The comparator invoked per element. 1918 1919 Returns: 1920 - Lodash chained on (Array): the new array of filtered values. 1921 1922 +/ 1923 auto ref xorWith(T, U)(auto ref T values, auto ref U comparator) { 1924 setupMemory(); 1925 Command c = Command("xorWith"); 1926 c.setHandleOrEval(values); 1927 c.setCallback(comparator); 1928 tryPut(c); 1929 return this; 1930 } 1931 1932 1933 /++ 1934 Creates an array of grouped elements, the first of which contains the 1935 first elements of the given arrays, the second of which contains the 1936 second elements of the given arrays, and so on. 1937 1938 Params: 1939 - [arrays] (...Array): The arrays to process. 1940 1941 Returns: 1942 - Lodash chained on (Array): the new array of grouped elements. 1943 1944 +/ 1945 auto ref zip(ARGS...)(auto ref ARGS arrays) { 1946 setupMemory(); 1947 Command c = Command("zip"); 1948 foreach(ref val; arrays) c.setHandleOrEval(val); 1949 tryPut(c); 1950 return this; 1951 } 1952 1953 1954 /++ 1955 This method is like _.fromPairs except that it accepts two arrays, 1956 one of property identifiers and one of corresponding values. 1957 1958 Params: 1959 - [values=[]] (Array): The property values. 1960 1961 Returns: 1962 - Lodash chained on (Object): the new object. 1963 1964 +/ 1965 auto ref zipObject(T)(auto ref T values) { 1966 setupMemory(); 1967 Command c = Command("zipObject"); 1968 c.setHandleOrEval(values); 1969 tryPut(c); 1970 return this; 1971 } 1972 1973 /++ 1974 This method is like _.zipObject except that it supports property paths. 1975 1976 Params: 1977 - [values=[]] (Array): The property values. 1978 1979 Returns: 1980 - Lodash chained on (Object): the new object. 1981 1982 +/ 1983 auto ref zipObjectDeep(T)(auto ref T values) { 1984 setupMemory(); 1985 Command c = Command("zipObjectDeep"); 1986 c.setHandleOrEval(values); 1987 tryPut(c); 1988 return this; 1989 } 1990 1991 /++ 1992 This method is like _.zip except that it accepts iteratee to specify 1993 how grouped values should be combined. The iteratee is invoked with 1994 the elements of each group: (...group). 1995 1996 Params: 1997 - [arrays] (...Array): The arrays to process. 1998 - [iteratee=_.identity] (Function): The function to combine grouped values. 1999 2000 Returns: 2001 - Lodash chained on (Object): the new object. 2002 2003 +/ 2004 auto ref zipWith(T, U = Any)(auto ref T arrays, auto ref U iteratee = U.init) { 2005 setupMemory(); 2006 Command c = Command("zipWith"); 2007 c.setHandleOrEval(arrays); 2008 if (iteratee) c.setCallback(iteratee); 2009 tryPut(c); 2010 return this; 2011 } 2012 2013 /++ 2014 Creates an object composed of keys generated from the results of running 2015 each element of collection thru iteratee. The corresponding value of 2016 each key is the number of times the key was returned by iteratee. The iteratee is invoked with one argument: (value). 2017 2018 Params: 2019 - [iteratee=_.identity] (Function): The iteratee to transform keys. 2020 2021 Returns: 2022 - Lodash chained on (Object): the composed aggregate object. 2023 2024 +/ 2025 auto ref countBy(T = Any)(auto ref T iteratee = T.init) { 2026 setupMemory(); 2027 Command c = Command("countBy"); 2028 if (iteratee) c.setCallback(iteratee); 2029 tryPut(c); 2030 return this; 2031 } 2032 2033 /++ 2034 Checks if predicate returns truthy for all elements of collection. 2035 Iteration is stopped once predicate returns falsey. The predicate is 2036 invoked with three arguments: (value, index|key, collection). 2037 2038 Note: This method returns true for empty collections because everything 2039 is true of elements of empty collections. 2040 2041 Params: 2042 - [predicate=_.identity] (Function): The function invoked per iteration. 2043 2044 Returns: 2045 - Lodash chained on (boolean): true if all elements pass the predicate check, else false. 2046 2047 +/ 2048 auto ref every(T = Any)(auto ref T predicate = T.init) { 2049 setupMemory(); 2050 Command c = Command("every"); 2051 if (predicate) c.setCallback(predicate); 2052 tryPut(c); 2053 return this; 2054 } 2055 2056 /++ 2057 Iterates over elements of collection, returning an array of all elements 2058 predicate returns truthy for. The predicate is invoked with three 2059 arguments: (value, index|key, collection). 2060 2061 Note: Unlike _.remove, this method returns a new array. 2062 2063 Params: 2064 - [predicate=_.identity] (Function): The function invoked per iteration. 2065 2066 Returns: 2067 - Lodash chained on (Array): the new filtered array. 2068 2069 +/ 2070 auto ref filter(T = Any)(auto ref T predicate = T.init) { 2071 setupMemory(); 2072 Command c = Command("filter"); 2073 if (predicate) c.setCallback(predicate); 2074 tryPut(c); 2075 return this; 2076 } 2077 2078 /++ 2079 Iterates over elements of collection, returning the first element 2080 predicate returns truthy for. The predicate is invoked with three 2081 arguments: (value, index|key, collection). 2082 2083 Params: 2084 - [predicate=_.identity] (Function): The function invoked per iteration. 2085 - [fromIndex=0] (number): The index to search from. 2086 2087 Returns: 2088 - Lodash chained on (*): the matched element, else undefined. 2089 2090 +/ 2091 auto ref find(T = Any, U = Any)(auto ref T predicate = T.init, auto ref U fromIndex = U.init) { 2092 setupMemory(); 2093 Command c = Command("find"); 2094 if (predicate) c.setCallback(predicate); 2095 if (fromIndex) c.setNumber(fromIndex); 2096 tryPut(c); 2097 return this; 2098 } 2099 2100 /++ 2101 This method is like _.find except that it iterates over elements of 2102 collection from right to left. 2103 2104 Params: 2105 - [predicate=_.identity] (Function): The function invoked per iteration. 2106 - [fromIndex=collection.length-1] (number): The index to search from. 2107 2108 Returns: 2109 - Lodash chained on (*): the matched element, else undefined. 2110 2111 +/ 2112 auto ref findLast(T = Any, U = Any)(auto ref T predicate = T.init, auto ref U fromIndex = U.init) { 2113 setupMemory(); 2114 Command c = Command("findLast"); 2115 if (predicate) c.setCallback(predicate); 2116 if (fromIndex) c.setNumber(fromIndex); 2117 tryPut(c); 2118 return this; 2119 } 2120 2121 /++ 2122 Creates a flattened array of values by running each element in collection 2123 thru iteratee and flattening the mapped results. The iteratee is invoked 2124 with three arguments: (value, index|key, collection). 2125 2126 Params: 2127 - [iteratee=_.identity] (Function): The function invoked per iteration. 2128 2129 Returns: 2130 - Lodash chained on (Array): the new flattened array. 2131 2132 +/ 2133 auto ref flatMap(T = Any)(auto ref T iteratee = T.init) { 2134 setupMemory(); 2135 Command c = Command("flatMap"); 2136 if (iteratee) c.setCallback(iteratee); 2137 tryPut(c); 2138 return this; 2139 } 2140 2141 2142 /++ 2143 This method is like _.flatMap except that it recursively flattens the 2144 mapped results. 2145 2146 Params: 2147 - [iteratee=_.identity] (Function): The function invoked per iteration. 2148 2149 Returns: 2150 - Lodash chained on (Array): the new flattened array. 2151 2152 +/ 2153 auto ref flatMapDeep(T = Any)(auto ref T iteratee = T.init) { 2154 setupMemory(); 2155 Command c = Command("flatMapDeep"); 2156 if (iteratee) c.setCallback(iteratee); 2157 tryPut(c); 2158 return this; 2159 } 2160 2161 2162 /++ 2163 This method is like _.flatMap except that it recursively flattens the 2164 mapped results up to depth times. 2165 2166 Params: 2167 - [iteratee=_.identity] (Function): The function invoked per iteration. 2168 - [depth=1] (number): The maximum recursion depth. 2169 2170 Returns: 2171 - Lodash chained on (Array): the new flattened array. 2172 2173 +/ 2174 auto ref flatMapDepth(T = Any, U = Any)(auto ref T iteratee = T.init, auto ref U depth = U.init) { 2175 setupMemory(); 2176 Command c = Command("flatMapDepth"); 2177 if (iteratee) c.setCallback(iteratee); 2178 if (depth) c.setNumber(depth); 2179 tryPut(c); 2180 return this; 2181 } 2182 2183 2184 /++ 2185 Iterates over elements of collection and invokes iteratee for each 2186 element. The iteratee is invoked with three arguments: 2187 (value, index|key, collection). Iteratee functions may exit iteration 2188 early by explicitly returning false. 2189 2190 Note: As with other "Collections" methods, objects with a "length" 2191 property are iterated like arrays. To avoid this behavior use _.forIn 2192 or _.forOwn for object iteration. 2193 2194 Params: 2195 - [iteratee=_.identity] (Function): The function invoked per iteration. 2196 2197 Returns: 2198 - Lodash chained on (*): collection. 2199 2200 +/ 2201 auto ref forEach(T = Any)(auto ref T iteratee = T.init) { 2202 setupMemory(); 2203 Command c = Command("forEach"); 2204 if (iteratee) c.setCallback(iteratee); 2205 tryPut(c); 2206 return this; 2207 } 2208 2209 2210 /++ 2211 This method is like _.forEach except that it iterates over elements of 2212 collection from right to left. 2213 2214 Params: 2215 - [iteratee=_.identity] (Function): The function invoked per iteration. 2216 2217 Returns: 2218 - Lodash chained on (*): collection. 2219 2220 +/ 2221 auto ref forEachRight(T = Any)(auto ref T iteratee = T.init) { 2222 setupMemory(); 2223 Command c = Command("forEachRight"); 2224 if (iteratee) c.setCallback(iteratee); 2225 tryPut(c); 2226 return this; 2227 } 2228 2229 2230 /++ 2231 Creates an object composed of keys generated from the results of running 2232 each element of collection thru iteratee. The order of grouped values is 2233 determined by the order they occur in collection. The corresponding value 2234 of each key is an array of elements responsible for generating the key. 2235 The iteratee is invoked with one argument: (value). 2236 2237 Params: 2238 - [iteratee=_.identity] (Function): The iteratee to transform keys. 2239 2240 Returns: 2241 - Lodash chained on (Object): the composed aggregate object. 2242 2243 +/ 2244 auto ref groupBy(T = Any)(auto ref T iteratee = T.init) { 2245 setupMemory(); 2246 Command c = Command("groupBy"); 2247 if (iteratee) c.setCallback(iteratee); 2248 tryPut(c); 2249 return this; 2250 } 2251 2252 /++ 2253 Checks if value is in collection. If collection is a string, it's checked 2254 for a substring of value, otherwise SameValueZero is used for equality 2255 comparisons. If fromIndex is negative, it's used as the offset from the 2256 end of collection. 2257 2258 Params: 2259 - value (*): The value to search for. 2260 - [fromIndex=0] (number): The index to search from. 2261 2262 Returns: 2263 - Lodash chained on (boolean): true if value is found, else false. 2264 2265 +/ 2266 auto ref includes(T, U = Any)(auto ref T value, auto ref U fromIndex = U.init) { 2267 setupMemory(); 2268 Command c = Command("includes"); 2269 c.setAnyValue(value); 2270 if (fromIndex) c.setNumber(fromIndex); 2271 tryPut(c); 2272 return this; 2273 } 2274 2275 /++ 2276 Invokes the method at path of each element in collection, returning an 2277 array of the results of each invoked method. Any additional arguments 2278 are provided to each invoked method. If path is a function, it's invoked 2279 for, and this bound to, each element in collection. 2280 2281 Params: 2282 - path (Array|Function|string): The path of the method to invoke or the function invoked per iteration. 2283 - [args] (...*): The arguments to invoke each method with. 2284 2285 Returns: 2286 - Lodash chained on (Array): the array of results. 2287 2288 +/ 2289 auto ref invokeMap(T, U = Any)(auto ref T path, auto ref U args = U.init) { 2290 setupMemory(); 2291 Command c = Command("invokeMap"); 2292 c.setAnyValue(path); 2293 if (args) c.setAnyValue(args); 2294 tryPut(c); 2295 return this; 2296 } 2297 2298 2299 /++ 2300 Creates an object composed of keys generated from the results of running 2301 each element of collection thru iteratee. The corresponding value of 2302 each key is the last element responsible for generating the key. The 2303 iteratee is invoked with one argument: (value). 2304 2305 Params: 2306 - [iteratee=_.identity] (Function): The iteratee to transform keys. 2307 2308 Returns: 2309 - Lodash chained on (Object): the composed aggregate object. 2310 2311 +/ 2312 auto ref keyBy(T = Any)(auto ref T iteratee = T.init) { 2313 setupMemory(); 2314 Command c = Command("keyBy"); 2315 if (iteratee) c.setCallback(iteratee); 2316 tryPut(c); 2317 return this; 2318 } 2319 2320 /++ 2321 Creates an array of values by running each element in collection thru 2322 iteratee. The iteratee is invoked with three arguments: 2323 (value, index|key, collection). 2324 2325 Many lodash methods are guarded to work as iteratees for methods like 2326 _.every, _.filter, _.map, _.mapValues, _.reject, and _.some. 2327 2328 The guarded methods are: 2329 ary, chunk, curry, curryRight, drop, dropRight, every, fill, invert, 2330 parseInt, random, range, rangeRight, repeat, sampleSize, slice, some, 2331 sortBy, split, take, takeRight, template, trim, trimEnd, trimStart, 2332 and words 2333 2334 Params: 2335 - [iteratee=_.identity] (Function): The function invoked per iteration. 2336 2337 Returns: 2338 - Lodash chained on (Object): the composed aggregate object. 2339 2340 +/ 2341 auto ref map(T = Any)(auto ref T iteratee = T.init) { 2342 setupMemory(); 2343 Command c = Command("map"); 2344 if (iteratee) c.setCallback(iteratee); 2345 tryPut(c); 2346 return this; 2347 } 2348 2349 2350 /++ 2351 This method is like _.sortBy except that it allows specifying the sort 2352 orders of the iteratees to sort by. If orders is unspecified, all values 2353 are sorted in ascending order. Otherwise, specify an order of "desc" for 2354 descending or "asc" for ascending sort order of corresponding values. 2355 2356 Params: 2357 - [iteratees=[_.identity]] (Array[]|Function[]|Object[]|string[]): The iteratees to sort by. 2358 - [orders] (string[]): The sort orders of iteratees. 2359 2360 Returns: 2361 - Lodash chained on (Array): the new sorted array. 2362 2363 +/ 2364 auto ref orderBy(T, U)(auto ref T iteratees, auto ref U orders) { 2365 setupMemory(); 2366 Command c = Command("orderBy"); 2367 c.setCallback(iteratees); 2368 c.setHandleOrEval(orders); 2369 tryPut(c); 2370 return this; 2371 } 2372 2373 /++ 2374 Creates an array of elements split into two groups, the first of which 2375 contains elements predicate returns truthy for, the second of which 2376 contains elements predicate returns falsey for. The predicate is invoked 2377 with one argument: (value). 2378 2379 Params: 2380 - [predicate=_.identity] (Function): The function invoked per iteration. 2381 2382 Returns: 2383 - Lodash chained on (Object): the array of grouped elements. 2384 2385 +/ 2386 auto ref partition(T = Any)(auto ref T iteratee = T.init) { 2387 setupMemory(); 2388 Command c = Command("partition"); 2389 if (iteratee) c.setCallback(iteratee); 2390 tryPut(c); 2391 return this; 2392 } 2393 2394 /++ 2395 Reduces collection to a value which is the accumulated result of running 2396 each element in collection thru iteratee, where each successive invocation 2397 is supplied the return value of the previous. If accumulator is not 2398 given, the first element of collection is used as the initial value. 2399 The iteratee is invoked with four arguments: 2400 (accumulator, value, index|key, collection). 2401 2402 Many lodash methods are guarded to work as iteratees for methods like 2403 _.reduce, _.reduceRight, and _.transform. 2404 2405 The guarded methods are: 2406 assign, defaults, defaultsDeep, includes, merge, orderBy, and sortBy 2407 2408 Params: 2409 - [iteratee=_.identity] (Function): The function invoked per iteration. 2410 - [accumulator] (*): The initial value. 2411 2412 Returns: 2413 - Lodash chained on (*): the accumulated value. 2414 2415 +/ 2416 auto ref reduce(T, U)(auto ref T iteratee, auto ref U accumulator) { 2417 setupMemory(); 2418 Command c = Command("reduce"); 2419 c.setCallback(iteratee); 2420 c.setHandleOrEval(orders); 2421 tryPut(c); 2422 return this; 2423 } 2424 2425 /++ 2426 This method is like _.reduce except that it iterates over elements of collection from right to left. 2427 2428 Params: 2429 - [iteratee=_.identity] (Function): The function invoked per iteration. 2430 - [accumulator] (*): The initial value. 2431 2432 Returns: 2433 - Lodash chained on (*): the accumulated value. 2434 2435 +/ 2436 auto ref reduceRight(T, U)(auto ref T iteratee, auto ref U accumulator) { 2437 setupMemory(); 2438 Command c = Command("reduceRight"); 2439 c.setCallback(iteratee); 2440 c.setHandleOrEval(orders); 2441 tryPut(c); 2442 return this; 2443 } 2444 2445 /++ 2446 The opposite of _.filter; this method returns the elements of collection that predicate does not return truthy for. 2447 2448 Params: 2449 - [predicate=_.identity] (Function): The function invoked per iteration. 2450 2451 Returns: 2452 - Lodash chained on (Array): the new filtered array. 2453 2454 +/ 2455 auto ref reject(T = Any)(auto ref T predicate = T.init) { 2456 setupMemory(); 2457 Command c = Command("reject"); 2458 if (predicate) c.setCallback(predicate); 2459 tryPut(c); 2460 return this; 2461 } 2462 2463 2464 /++ 2465 Gets a random element from collection. 2466 2467 Returns: 2468 - Lodash chained on (*): the random element. 2469 2470 +/ 2471 auto ref sample()() { 2472 setupMemory(); 2473 Command c = Command("sample"); 2474 tryPut(c); 2475 return this; 2476 } 2477 2478 /++ 2479 Gets n random elements at unique keys from collection up to the size of collection. 2480 2481 Params: 2482 - [n=1] (number): The number of elements to sample. 2483 2484 Returns: 2485 - Lodash chained on (Array): the random elements. 2486 2487 +/ 2488 auto ref sampleSize(T = Any)(auto ref T n = T.init) { 2489 setupMemory(); 2490 Command c = Command("sampleSize"); 2491 if (n) c.setNumber(n); 2492 tryPut(c); 2493 return this; 2494 } 2495 2496 /++ 2497 Creates an array of shuffled values, using a version of the 2498 Fisher-Yates shuffle. 2499 2500 Returns: 2501 - Lodash chained on (Array): the new shuffled array. 2502 2503 +/ 2504 auto ref shuffle()() { 2505 setupMemory(); 2506 Command c = Command("shuffle"); 2507 tryPut(c); 2508 return this; 2509 } 2510 2511 /++ 2512 Gets the size of collection by returning its length for array-like values 2513 or the number of own enumerable string keyed properties for objects. 2514 2515 Returns: 2516 - Lodash chained on (number): the collection size. 2517 2518 +/ 2519 auto ref size()() { 2520 setupMemory(); 2521 Command c = Command("size"); 2522 tryPut(c); 2523 return this; 2524 } 2525 2526 /++ 2527 Checks if predicate returns truthy for any element of collection. 2528 Iteration is stopped once predicate returns truthy. The predicate is 2529 invoked with three arguments: (value, index|key, collection). 2530 2531 Params: 2532 - [predicate=_.identity] (Function): The function invoked per iteration. 2533 2534 Returns: 2535 - Lodash chained on (Array): the new filtered array. 2536 2537 +/ 2538 auto ref some(T = Any)(auto ref T predicate = T.init) { 2539 setupMemory(); 2540 Command c = Command("some"); 2541 if (predicate) c.setCallback(predicate); 2542 tryPut(c); 2543 return this; 2544 } 2545 2546 /++ 2547 Creates an array of elements, sorted in ascending order by the results 2548 of running each element in a collection thru each iteratee. This 2549 method performs a stable sort, that is, it preserves the original 2550 sort order of equal elements. The iteratees are invoked with one 2551 argument: (value). 2552 2553 Params: 2554 - [iteratees=[_.identity]] (...(Function|Function[])): The iteratees to sort by. 2555 2556 Returns: 2557 - Lodash chained on (Array): the new sorted array. 2558 2559 +/ 2560 auto ref sortBy(ARGS...)(auto ref ARGS iteratees) { 2561 setupMemory(); 2562 Command c = Command("sortBy"); 2563 foreach (ref iteratee; iteratees) c.setCallback(iteratee); 2564 tryPut(c); 2565 return this; 2566 } 2567 2568 2569 /++ 2570 Gets the timestamp of the number of milliseconds that have elapsed since 2571 the Unix epoch (1 January 1970 00:00:00 UTC). 2572 2573 Returns: 2574 - Lodash chained on (number): the timestamp. 2575 2576 +/ 2577 auto ref now()() { 2578 setupMemory(); 2579 Command c = Command("now"); 2580 tryPut(c); 2581 return this; 2582 } 2583 2584 /++ 2585 Gets the timestamp of the number of milliseconds that have elapsed since 2586 the Unix epoch (1 January 1970 00:00:00 UTC). 2587 2588 Returns: 2589 - Lodash chained on (Array): the cast array. 2590 2591 +/ 2592 auto ref castArray()() { 2593 setupMemory(); 2594 Command c = Command("castArray"); 2595 tryPut(c); 2596 return this; 2597 } 2598 2599 /++ 2600 Creates a shallow clone of value. 2601 2602 Note: This method is loosely based on the structured clone algorithm and 2603 supports cloning arrays, array buffers, booleans, date objects, maps, 2604 numbers, Object objects, regexes, sets, strings, symbols, and typed arrays. The own enumerable properties of arguments objects are cloned as plain objects. An empty object is returned for uncloneable values such as error objects, functions, DOM nodes, and WeakMaps. 2605 2606 Returns: 2607 - Lodash chained on (*): the cloned value 2608 2609 +/ 2610 auto ref clone()() { 2611 setupMemory(); 2612 Command c = Command("clone"); 2613 tryPut(c); 2614 return this; 2615 } 2616 2617 /++ 2618 This method is like _.clone except that it recursively clones value. 2619 2620 Returns: 2621 - Lodash chained on (*): the deep cloned value. 2622 2623 +/ 2624 auto ref cloneDeep()() { 2625 setupMemory(); 2626 Command c = Command("cloneDeep"); 2627 tryPut(c); 2628 return this; 2629 } 2630 2631 /++ 2632 This method is like _.cloneWith except that it recursively clones value. 2633 2634 Params: 2635 - [customizer] (Function): The function to customize cloning. 2636 2637 Returns: 2638 - Lodash chained on (*): the deep cloned value. 2639 2640 +/ 2641 auto ref cloneDeepWith(T)(auto ref T customizer) { 2642 setupMemory(); 2643 Command c = Command("cloneDeepWith"); 2644 c.setCallback(customizer); 2645 tryPut(c); 2646 return this; 2647 } 2648 2649 /++ 2650 This method is like _.clone except that it accepts customizer which is 2651 invoked to produce the cloned value. If customizer returns undefined, 2652 cloning is handled by the method instead. The customizer is invoked 2653 with up to four arguments; (value [, index|key, object, stack]). 2654 2655 Params: 2656 - [customizer] (Function): The function to customize cloning. 2657 2658 Returns: 2659 - Lodash chained on (*): the cloned value. 2660 2661 +/ 2662 auto ref cloneWith(T)(auto ref T customizer) { 2663 setupMemory(); 2664 Command c = Command("cloneWith"); 2665 c.setCallback(customizer); 2666 tryPut(c); 2667 return this; 2668 } 2669 2670 /++ 2671 Checks if object conforms to source by invoking the predicate properties 2672 of source with the corresponding property values of object. 2673 2674 Note: This method is equivalent to _.conforms when source is partially 2675 2676 Params: 2677 - source (Object): The object of property predicates to conform to. 2678 2679 Returns: 2680 - Lodash chained on (boolean): true if object conforms, else false. 2681 2682 +/ 2683 auto ref conformsTo(T)(auto ref T source) { 2684 setupMemory(); 2685 Command c = Command("conformsTo"); 2686 c.setHandleOrEval(source); 2687 tryPut(c); 2688 return this; 2689 } 2690 2691 /++ 2692 Performs a SameValueZero comparison between two values to determine if they are equivalent. 2693 2694 Params: 2695 - other (*): The other value to compare. 2696 2697 Returns: 2698 - Lodash chained on (boolean): true if the values are equivalent, else false. 2699 2700 +/ 2701 auto ref eq(T)(auto ref T other) { 2702 setupMemory(); 2703 Command c = Command("eq"); 2704 c.setAnyValue(other); 2705 tryPut(c); 2706 return this; 2707 } 2708 2709 /++ 2710 Checks if value is greater than other. 2711 2712 Params: 2713 - other (*): The other value to compare. 2714 2715 Returns: 2716 - Lodash chained on (boolean): true if value is greater than other, else false. 2717 2718 +/ 2719 auto ref gt(T)(auto ref T other) { 2720 setupMemory(); 2721 Command c = Command("gt"); 2722 c.setAnyValue(other); 2723 tryPut(c); 2724 return this; 2725 } 2726 2727 /++ 2728 Checks if value is greater than or equal to other. 2729 2730 Params: 2731 - other (*): The other value to compare. 2732 2733 Returns: 2734 - Lodash chained on (boolean): true if value is greater than or equal to other, else false. 2735 2736 +/ 2737 auto ref gte(T)(auto ref T other) { 2738 setupMemory(); 2739 Command c = Command("gte"); 2740 c.setAnyValue(other); 2741 tryPut(c); 2742 return this; 2743 } 2744 2745 2746 /++ 2747 Checks if value is likely an arguments object. 2748 2749 Returns: 2750 - Lodash chained on (boolean): true if value is an arguments object, else false. 2751 2752 +/ 2753 auto ref isArguments()() { 2754 setupMemory(); 2755 Command c = Command("isArguments"); 2756 tryPut(c); 2757 return this; 2758 } 2759 2760 2761 /++ 2762 Checks if value is classified as an Array object. 2763 2764 Returns: 2765 - Lodash chained on (boolean): true if value is an array, else false. 2766 2767 +/ 2768 auto ref isArray()() { 2769 setupMemory(); 2770 Command c = Command("isArray"); 2771 tryPut(c); 2772 return this; 2773 } 2774 2775 /++ 2776 Checks if value is classified as an ArrayBuffer object. 2777 2778 Returns: 2779 - Lodash chained on (boolean): true if value is an array buffer, else false. 2780 2781 +/ 2782 auto ref isArrayBuffer()() { 2783 setupMemory(); 2784 Command c = Command("isArrayBuffer"); 2785 tryPut(c); 2786 return this; 2787 } 2788 2789 /++ 2790 Checks if value is array-like. A value is considered array-like if it's not a 2791 function and has a value.length that's an integer greater than or equal to 0 2792 and less than or equal to Number.MAX_SAFE_INTEGER. 2793 2794 Returns: 2795 - Lodash chained on (boolean): true if value is array-like, else false. 2796 2797 +/ 2798 auto ref isArrayLike()() { 2799 setupMemory(); 2800 Command c = Command("isArrayLike"); 2801 tryPut(c); 2802 return this; 2803 } 2804 2805 /++ 2806 This method is like _.isArrayLike except that it also checks if value is an object. 2807 2808 Returns: 2809 - Lodash chained on (boolean): true if value is an array-like object, else false. 2810 2811 +/ 2812 auto ref isArrayLikeObject()() { 2813 setupMemory(); 2814 Command c = Command("isArrayLikeObject"); 2815 tryPut(c); 2816 return this; 2817 } 2818 2819 /++ 2820 Checks if value is classified as a boolean primitive or object. 2821 2822 Returns: 2823 - Lodash chained on (boolean): true if value is a boolean, else false. 2824 2825 +/ 2826 auto ref isBoolean()() { 2827 setupMemory(); 2828 Command c = Command("isBoolean"); 2829 tryPut(c); 2830 return this; 2831 } 2832 2833 /++ 2834 Checks if value is a buffer. 2835 2836 Returns: 2837 - Lodash chained on (boolean): true if value is a buffer, else false. 2838 2839 +/ 2840 auto ref isBuffer()() { 2841 setupMemory(); 2842 Command c = Command("isBuffer"); 2843 tryPut(c); 2844 return this; 2845 } 2846 2847 /++ 2848 Checks if value is classified as a Date object. 2849 2850 Returns: 2851 - Lodash chained on (boolean): true if value is a date object, else false. 2852 2853 +/ 2854 auto ref isDate()() { 2855 setupMemory(); 2856 Command c = Command("isDate"); 2857 tryPut(c); 2858 return this; 2859 } 2860 2861 2862 /++ 2863 Checks if value is likely a DOM element. 2864 2865 Returns: 2866 - Lodash chained on (boolean): true if value is a DOM element, else false. 2867 2868 +/ 2869 auto ref isElement()() { 2870 setupMemory(); 2871 Command c = Command("isElement"); 2872 tryPut(c); 2873 return this; 2874 } 2875 /++ 2876 Checks if value is an empty object, collection, map, or set. 2877 2878 Objects are considered empty if they have no own enumerable string keyed properties. 2879 2880 Array-like values such as arguments objects, arrays, buffers, strings, or 2881 jQuery-like collections are considered empty if they have a length of 0. Similarly, 2882 maps and sets are considered empty if they have a size of 0. 2883 2884 Returns: 2885 - Lodash chained on (boolean): true if value is empty, else false. 2886 2887 +/ 2888 auto ref isEmpty()() { 2889 setupMemory(); 2890 Command c = Command("isEmpty"); 2891 tryPut(c); 2892 return this; 2893 } 2894 2895 /++ 2896 Performs a deep comparison between two values to determine if they are equivalent. 2897 2898 Note: This method supports comparing arrays, array buffers, booleans, date objects, 2899 error objects, maps, numbers, Object objects, regexes, sets, strings, symbols, and 2900 typed arrays. Object objects are compared by their own, not inherited, enumerable 2901 properties. Functions and DOM nodes are compared by strict equality, i.e. ===. 2902 2903 Params: 2904 - other (*): The other value to compare. 2905 2906 Returns: 2907 - Lodash chained on (boolean): true if the values are equivalent, else false. 2908 2909 +/ 2910 auto ref isEqual(T)(auto ref T other) { 2911 setupMemory(); 2912 Command c = Command("isEqual"); 2913 c.setAnyValue(other); 2914 tryPut(c); 2915 return this; 2916 } 2917 2918 /++ 2919 This method is like _.isEqual except that it accepts customizer which is 2920 invoked to compare values. If customizer returns undefined, comparisons 2921 are handled by the method instead. The customizer is invoked with up to 2922 six arguments: (objValue, othValue [, index|key, object, other, stack]). 2923 2924 Params: 2925 - other (*): The other value to compare. 2926 - [customizer] (Function): The function to customize comparisons. 2927 2928 Returns: 2929 - Lodash chained on (boolean): true if the values are equivalent, else false. 2930 2931 +/ 2932 auto ref isEqualWith(T, U)(auto ref T other, auto ref U customizer) { 2933 setupMemory(); 2934 Command c = Command("isEqual"); 2935 c.setAnyValue(other); 2936 c.setCallback(customizer); 2937 tryPut(c); 2938 return this; 2939 } 2940 2941 2942 /++ 2943 Checks if value is an Error, EvalError, RangeError, ReferenceError, 2944 SyntaxError, TypeError, or URIError object. 2945 2946 Returns: 2947 - Lodash chained on (boolean): true if value is an error object, else false. 2948 2949 +/ 2950 auto ref isError()() { 2951 setupMemory(); 2952 Command c = Command("isError"); 2953 tryPut(c); 2954 return this; 2955 } 2956 2957 2958 /++ 2959 Checks if value is a finite primitive number. 2960 2961 Returns: 2962 - Lodash chained on (boolean): true if value is a finite number, else false. 2963 2964 +/ 2965 auto ref isFinite()() { 2966 setupMemory(); 2967 Command c = Command("isFinite"); 2968 tryPut(c); 2969 return this; 2970 } 2971 2972 /++ 2973 Checks if value is classified as a Function object. 2974 2975 Returns: 2976 - Lodash chained on (boolean): true if value is a function, else false. 2977 2978 +/ 2979 auto ref isFunction()() { 2980 setupMemory(); 2981 Command c = Command("isFunction"); 2982 tryPut(c); 2983 return this; 2984 } 2985 /++ 2986 Checks if value is an integer. 2987 2988 Returns: 2989 - Lodash chained on (boolean): true if value is an integer, else false. 2990 2991 +/ 2992 auto ref isInteger()() { 2993 setupMemory(); 2994 Command c = Command("isInteger"); 2995 tryPut(c); 2996 return this; 2997 } 2998 /++ 2999 Checks if value is a valid array-like length. 3000 3001 Note: This method is loosely based on ToLength. 3002 3003 Returns: 3004 - Lodash chained on (boolean): true if value is a valid length, else false. 3005 3006 +/ 3007 auto ref isLength()() { 3008 setupMemory(); 3009 Command c = Command("isLength"); 3010 tryPut(c); 3011 return this; 3012 } 3013 /++ 3014 Checks if value is classified as a Map object. 3015 3016 Note: This method is loosely based on ToLength. 3017 3018 Returns: 3019 - Lodash chained on (boolean): true if value is a map, else false. 3020 3021 +/ 3022 auto ref isMap()() { 3023 setupMemory(); 3024 Command c = Command("isMap"); 3025 tryPut(c); 3026 return this; 3027 } 3028 3029 3030 /++ 3031 Performs a partial deep comparison between object and source to 3032 determine if object contains equivalent property values. 3033 3034 Note: This method is equivalent to _.matches when source is partially 3035 applied. 3036 3037 Partial comparisons will match empty array and empty object source values 3038 against any array or object value, respectively. See _.isEqual for a list 3039 of supported value comparisons. 3040 3041 Params: 3042 - source (Object): The object of property values to match. 3043 3044 Returns: 3045 - Lodash chained on (boolean): true if object is a match, else false. 3046 3047 +/ 3048 auto ref isMatch(T)(auto ref T other) { 3049 setupMemory(); 3050 Command c = Command("isMatch"); 3051 c.setHandleOrEval(other); 3052 tryPut(c); 3053 return this; 3054 } 3055 /++ 3056 This method is like _.isMatch except that it accepts customizer which is 3057 invoked to compare values. If customizer returns undefined, comparisons 3058 are handled by the method instead. The customizer is invoked with five 3059 arguments: (objValue, srcValue, index|key, object, source). 3060 3061 Params: 3062 - source (Object): The object of property values to match. 3063 - [customizer] (Function): The function to customize comparisons. 3064 3065 Returns: 3066 - Lodash chained on (boolean): true if object is a match, else false. 3067 3068 +/ 3069 auto ref isMatchWith(T, U)(auto ref T other, auto ref U customizer) { 3070 setupMemory(); 3071 Command c = Command("isMatchWith"); 3072 c.setHandleOrEval(other); 3073 c.setCallback(customizer); 3074 tryPut(c); 3075 return this; 3076 } 3077 3078 /++ 3079 Checks if value is NaN. 3080 3081 Note: This method is based on Number.isNaN and is not the same as 3082 global isNaN which returns true for undefined and other non-number 3083 values. 3084 3085 Returns: 3086 - Lodash chained on (boolean): true if value is NaN, else false. 3087 3088 +/ 3089 auto ref isNaN()() { 3090 setupMemory(); 3091 Command c = Command("isNaN"); 3092 tryPut(c); 3093 return this; 3094 } 3095 /++ 3096 Checks if value is a pristine native function. 3097 3098 Note: This method can't reliably detect native functions in the 3099 presence of the core-js package because core-js circumvents this 3100 kind of detection. Despite multiple requests, the core-js 3101 maintainer has made it clear: any attempt to fix the detection 3102 will be obstructed. As a result, we're left with little choice 3103 but to throw an error. Unfortunately, this also affects packages, 3104 like babel-polyfill, which rely on core-js. 3105 3106 Returns: 3107 - Lodash chained on (boolean): true if value is a native function, else false. 3108 3109 +/ 3110 auto ref isNative()() { 3111 setupMemory(); 3112 Command c = Command("isNative"); 3113 tryPut(c); 3114 return this; 3115 } 3116 3117 /++ 3118 Checks if value is null or undefined. 3119 3120 Returns: 3121 - Lodash chained on (boolean): true if value is nullish, else false. 3122 3123 +/ 3124 auto ref isNil()() { 3125 setupMemory(); 3126 Command c = Command("isNil"); 3127 tryPut(c); 3128 return this; 3129 } 3130 /++ 3131 Checks if value is null or undefined. 3132 3133 Returns: 3134 - Lodash chained on (boolean): true if value is null, else false. 3135 3136 +/ 3137 auto ref isNull()() { 3138 setupMemory(); 3139 Command c = Command("isNull"); 3140 tryPut(c); 3141 return this; 3142 } 3143 /++ 3144 Checks if value is classified as a Number primitive or object. 3145 3146 Note: To exclude Infinity, -Infinity, and NaN, which are classified 3147 as numbers, use the _.isFinite method. 3148 3149 Returns: 3150 - Lodash chained on (boolean): true if value is a number, else false. 3151 3152 +/ 3153 auto ref isNumber()() { 3154 setupMemory(); 3155 Command c = Command("isNumber"); 3156 tryPut(c); 3157 return this; 3158 } 3159 /++ 3160 Checks if value is the language type of Object. 3161 (e.g. arrays, functions, objects, regexes, new Number(0), and new String('')) 3162 3163 Returns: 3164 - Lodash chained on (boolean): true if value is an object, else false. 3165 3166 +/ 3167 auto ref isObject()() { 3168 setupMemory(); 3169 Command c = Command("isObject"); 3170 tryPut(c); 3171 return this; 3172 } 3173 /++ 3174 Checks if value is object-like. A value is object-like if it's not 3175 null and has a typeof result of "object". 3176 3177 Returns: 3178 - Lodash chained on (boolean): true if value is object-like, else false. 3179 3180 +/ 3181 auto ref isObjectLike()() { 3182 setupMemory(); 3183 Command c = Command("isObjectLike"); 3184 tryPut(c); 3185 return this; 3186 } 3187 /++ 3188 Checks if value is a plain object, that is, an object created by the Object 3189 constructor or one with a [[Prototype]] of null. 3190 3191 Returns: 3192 - Lodash chained on (boolean): true if value is a plain object, else false. 3193 3194 +/ 3195 auto ref isPlainObject()() { 3196 setupMemory(); 3197 Command c = Command("isPlainObject"); 3198 tryPut(c); 3199 return this; 3200 } 3201 /++ 3202 Checks if value is classified as a RegExp object. 3203 3204 Returns: 3205 - Lodash chained on (boolean): true if value is a regexp, else false. 3206 3207 +/ 3208 auto ref isRegExp()() { 3209 setupMemory(); 3210 Command c = Command("isRegExp"); 3211 tryPut(c); 3212 return this; 3213 } 3214 /++ 3215 Checks if value is a safe integer. An integer is safe if it's an IEEE-754 3216 double precision number which isn't the result of a rounded unsafe integer. 3217 3218 Note: This method is based on Number.isSafeInteger. 3219 3220 Returns: 3221 - Lodash chained on (boolean): true if value is a safe integer, else false. 3222 3223 +/ 3224 auto ref isSafeInteger()() { 3225 setupMemory(); 3226 Command c = Command("isSafeInteger"); 3227 tryPut(c); 3228 return this; 3229 } 3230 /++ 3231 Checks if value is classified as a Set object. 3232 3233 Returns: 3234 - Lodash chained on (boolean): true if value is a set, else false. 3235 3236 +/ 3237 auto ref isSet()() { 3238 setupMemory(); 3239 Command c = Command("isSet"); 3240 tryPut(c); 3241 return this; 3242 } 3243 3244 /++ 3245 Checks if value is classified as a String primitive or object. 3246 3247 Returns: 3248 - Lodash chained on (boolean): true if value is a string, else false. 3249 3250 +/ 3251 auto ref isString()() { 3252 setupMemory(); 3253 Command c = Command("isString"); 3254 tryPut(c); 3255 return this; 3256 } 3257 /++ 3258 Checks if value is classified as a Symbol primitive or object. 3259 3260 Returns: 3261 - Lodash chained on (boolean): true if value is a symbol, else false. 3262 3263 +/ 3264 auto ref isSymbol()() { 3265 setupMemory(); 3266 Command c = Command("isSymbol"); 3267 tryPut(c); 3268 return this; 3269 } 3270 /++ 3271 Checks if value is classified as a typed array. 3272 3273 Returns: 3274 - Lodash chained on (boolean): true if value is a typed array, else false. 3275 3276 +/ 3277 auto ref isTypedArray()() { 3278 setupMemory(); 3279 Command c = Command("isTypedArray"); 3280 tryPut(c); 3281 return this; 3282 } 3283 /++ 3284 Checks if value is undefined. 3285 3286 Returns: 3287 - Lodash chained on (boolean): true if value is undefined, else false. 3288 3289 +/ 3290 auto ref isUndefined()() { 3291 setupMemory(); 3292 Command c = Command("isUndefined"); 3293 tryPut(c); 3294 return this; 3295 } 3296 /++ 3297 Checks if value is classified as a WeakMap object. 3298 3299 Returns: 3300 - Lodash chained on (boolean): true if value is a weak map, else false. 3301 3302 +/ 3303 auto ref isWeakMap()() { 3304 setupMemory(); 3305 Command c = Command("isWeakMap"); 3306 tryPut(c); 3307 return this; 3308 } 3309 3310 /++ 3311 Checks if value is classified as a WeakSet object. 3312 3313 Returns: 3314 - Lodash chained on (boolean): true if value is a weak set, else false. 3315 3316 +/ 3317 auto ref isWeakSet()() { 3318 setupMemory(); 3319 Command c = Command("isWeakSet"); 3320 tryPut(c); 3321 return this; 3322 } 3323 3324 3325 /++ 3326 Checks if value is less than other. 3327 3328 Params: 3329 - other (*): The other value to compare. 3330 3331 Returns: 3332 - Lodash chained on (boolean): true if value is less than other, else false. 3333 3334 +/ 3335 auto ref lt(T)(auto ref T other) { 3336 setupMemory(); 3337 Command c = Command("lt"); 3338 c.setAnyValue(other); 3339 tryPut(c); 3340 return this; 3341 } 3342 /++ 3343 Checks if value is less than or equal to other. 3344 3345 Params: 3346 - other (*): The other value to compare. 3347 3348 Returns: 3349 - Lodash chained on (boolean): true if value is less than or equal to other, else false. 3350 3351 +/ 3352 auto ref lte(T)(auto ref T other) { 3353 setupMemory(); 3354 Command c = Command("lte"); 3355 c.setAnyValue(other); 3356 tryPut(c); 3357 return this; 3358 } 3359 3360 3361 /++ 3362 Converts value to an array. 3363 _.toArray({ 'a': 1, 'b': 2 }); 3364 // => [1, 2] 3365 3366 _.toArray('abc'); 3367 // => ['a', 'b', 'c'] 3368 3369 _.toArray(1); 3370 // => [] 3371 Returns: 3372 - Lodash chained on (Array): the converted array. 3373 3374 +/ 3375 auto ref toArray()() { 3376 setupMemory(); 3377 Command c = Command("toArray"); 3378 tryPut(c); 3379 return this; 3380 } 3381 /++ 3382 Converts value to a finite number. 3383 3384 _.toFinite(Number.MIN_VALUE); 3385 // => 5e-324 3386 3387 _.toFinite(Infinity); 3388 // => 1.7976931348623157e+308 3389 3390 Returns: 3391 - Lodash chained on (number): the converted number. 3392 3393 +/ 3394 auto ref toFinite()() { 3395 setupMemory(); 3396 Command c = Command("toFinite"); 3397 tryPut(c); 3398 return this; 3399 } 3400 /++ 3401 Converts value to an integer. 3402 3403 _.toInteger(Number.MIN_VALUE); 3404 // => 0 3405 _.toInteger(Infinity); 3406 // => 1.7976931348623157e+308 3407 3408 Returns: 3409 - Lodash chained on (number): the converted integer. 3410 3411 +/ 3412 auto ref toInteger()() { 3413 setupMemory(); 3414 Command c = Command("toInteger"); 3415 tryPut(c); 3416 return this; 3417 } 3418 /++ 3419 Converts value to an integer suitable for use as the length of an array-like object. 3420 3421 Note: This method is based on ToLength. 3422 3423 _.toLength(Number.MIN_VALUE); 3424 // => 0 3425 3426 _.toLength(Infinity); 3427 // => 4294967295 3428 3429 Returns: 3430 - Lodash chained on (number): the converted integer. 3431 3432 +/ 3433 auto ref toLength()() { 3434 setupMemory(); 3435 Command c = Command("toLength"); 3436 tryPut(c); 3437 return this; 3438 } 3439 3440 /++ 3441 Converts value to a number. 3442 3443 Note: This method is based on ToLength. 3444 3445 _.toNumber(Number.MIN_VALUE); 3446 // => 5e-324 3447 3448 _.toNumber(Infinity); 3449 // => Infinity 3450 3451 Returns: 3452 - Lodash chained on (number): the number. 3453 3454 +/ 3455 auto ref toNumber()() { 3456 setupMemory(); 3457 Command c = Command("toNumber"); 3458 tryPut(c); 3459 return this; 3460 } 3461 /++ 3462 Converts value to a plain object flattening inherited enumerable string 3463 keyed properties of value to own properties of the plain object. 3464 3465 function Foo() { 3466 this.b = 2; 3467 } 3468 3469 Foo.prototype.c = 3; 3470 3471 _.assign({ 'a': 1 }, new Foo); 3472 // => { 'a': 1, 'b': 2 } 3473 3474 _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 3475 // => { 'a': 1, 'b': 2, 'c': 3 } 3476 3477 Returns: 3478 - Lodash chained on (Object): the converted plain object. 3479 3480 +/ 3481 auto ref toPlainObject()() { 3482 setupMemory(); 3483 Command c = Command("toPlainObject"); 3484 tryPut(c); 3485 return this; 3486 } 3487 /++ 3488 Converts value to a safe integer. A safe integer can be compared and 3489 represented correctly. 3490 3491 _.toSafeInteger(Number.MIN_VALUE); 3492 // => 0 3493 3494 _.toSafeInteger(Infinity); 3495 // => 9007199254740991 3496 3497 Returns: 3498 - Lodash chained on (number): the converted integer. 3499 3500 +/ 3501 auto ref toSafeInteger()() { 3502 setupMemory(); 3503 Command c = Command("toSafeInteger"); 3504 tryPut(c); 3505 return this; 3506 } 3507 3508 /++ 3509 3510 Converts value to a string. An empty string is returned for null 3511 and undefined values. The sign of -0 is preserved. 3512 3513 Returns: 3514 - Lodash chained on (string): the converted string. 3515 3516 +/ 3517 auto ref toString()() { 3518 setupMemory(); 3519 Command c = Command("toString"); 3520 tryPut(c); 3521 return this; 3522 } 3523 3524 /++ 3525 3526 Adds two numbers. 3527 3528 Params: 3529 - (number): The second number in an addition. 3530 3531 Returns: 3532 - Lodash chained on (number): the total. 3533 3534 +/ 3535 auto ref add(T)(auto ref T other) { 3536 setupMemory(); 3537 Command c = Command("number"); 3538 c.setNumber(other); 3539 tryPut(c); 3540 return this; 3541 } 3542 3543 /++ 3544 3545 Computes number rounded up to precision. 3546 3547 Params: 3548 - [precision=0] (number): The precision to round up to. 3549 3550 Returns: 3551 - Lodash chained on (number): the rounded up number. 3552 3553 +/ 3554 auto ref ceil(T = Any)(auto ref T precision = T.init) { 3555 setupMemory(); 3556 Command c = Command("ceil"); 3557 if (precision) c.setNumber(precision); 3558 tryPut(c); 3559 return this; 3560 } 3561 3562 /++ 3563 3564 Divide two numbers. 3565 3566 Params: 3567 - (number): The second number in a division. 3568 3569 Returns: 3570 - Lodash chained on (number): the quotient. 3571 3572 +/ 3573 auto ref divide(T)(auto ref T other) { 3574 setupMemory(); 3575 Command c = Command("divide"); 3576 c.setNumber(other); 3577 tryPut(c); 3578 return this; 3579 } 3580 3581 /++ 3582 3583 Computes number rounded down to precision. 3584 3585 Params: 3586 - [precision=0] (number): The precision to round down to. 3587 3588 Returns: 3589 - Lodash chained on (number): the rounded down number. 3590 3591 +/ 3592 auto ref floor(T = Any)(auto ref T precision = T.init) { 3593 setupMemory(); 3594 Command c = Command("floor"); 3595 if (precision) c.setNumber(precision); 3596 tryPut(c); 3597 return this; 3598 } 3599 3600 /++ 3601 3602 Computes the maximum value of array. If array is empty or falsey, undefined is returned. 3603 3604 Returns: 3605 - Lodash chained on (*): the maximum value. 3606 3607 +/ 3608 auto ref max()() { 3609 setupMemory(); 3610 Command c = Command("max"); 3611 tryPut(c); 3612 return this; 3613 } 3614 3615 /++ 3616 3617 This method is like _.max except that it accepts iteratee which is invoked for each 3618 element in array to generate the criterion by which the value is ranked. The 3619 iteratee is invoked with one argument: (value). 3620 3621 Params: 3622 - [iteratee=_.identity] (Function): The iteratee invoked per element. 3623 3624 Returns: 3625 - Lodash chained on (*): the maximum value. 3626 3627 +/ 3628 auto ref maxBy(T = Any)(auto ref T iteratee = T.init) { 3629 setupMemory(); 3630 Command c = Command("maxBy"); 3631 if (iteratee) c.setCallback(iteratee); 3632 tryPut(c); 3633 return this; 3634 } 3635 3636 /++ 3637 3638 Computes the mean of the values in array. 3639 3640 Returns: 3641 - Lodash chained on (number): the mean. 3642 3643 +/ 3644 auto ref mean()() { 3645 setupMemory(); 3646 Command c = Command("mean"); 3647 tryPut(c); 3648 return this; 3649 } 3650 3651 /++ 3652 3653 This method is like _.mean except that it accepts iteratee which is 3654 invoked for each element in array to generate the value to be averaged. 3655 The iteratee is invoked with one argument: (value). 3656 3657 Params: 3658 - [iteratee=_.identity] (Function): The iteratee invoked per element. 3659 3660 Returns: 3661 - Lodash chained on (number): the mean. 3662 3663 +/ 3664 auto ref meanBy(T = Any)(auto ref T iteratee = T.init) { 3665 setupMemory(); 3666 Command c = Command("meanBy"); 3667 if (iteratee) c.setCallback(iteratee); 3668 tryPut(c); 3669 return this; 3670 } 3671 3672 /++ 3673 3674 Computes the minimum value of array. If array is empty or falsey, 3675 undefined is returned. 3676 3677 Returns: 3678 - Lodash chained on (*): the minimum value. 3679 3680 +/ 3681 auto ref min()() { 3682 setupMemory(); 3683 Command c = Command("min"); 3684 tryPut(c); 3685 return this; 3686 } 3687 3688 3689 /++ 3690 3691 This method is like _.min except that it accepts iteratee which is invoked 3692 for each element in array to generate the criterion by which the value is 3693 ranked. The iteratee is invoked with one argument: (value). 3694 3695 Params: 3696 - [iteratee=_.identity] (Function): The iteratee invoked per element. 3697 3698 Returns: 3699 - Lodash chained on (*): the minimum value. 3700 3701 +/ 3702 auto ref minBy(T = Any)(auto ref T iteratee = T.init) { 3703 setupMemory(); 3704 Command c = Command("minBy"); 3705 if (iteratee) c.setCallback(iteratee); 3706 tryPut(c); 3707 return this; 3708 } 3709 3710 /++ 3711 3712 Multiply two numbers. 3713 3714 Params: 3715 - (number): The second number in a multiplication. 3716 3717 Returns: 3718 - Lodash chained on (number): the product. 3719 3720 +/ 3721 auto ref multiply(T)(auto ref T other) { 3722 setupMemory(); 3723 Command c = Command("multiply"); 3724 c.setNumber(other); 3725 tryPut(c); 3726 return this; 3727 } 3728 3729 /++ 3730 3731 Computes number rounded to precision. 3732 3733 Params: 3734 - [precision=0] (number): The precision to round to. 3735 3736 Returns: 3737 - Lodash chained on (number): the rounded number. 3738 3739 +/ 3740 auto ref round(T = Any)(auto ref T precision = T.init) { 3741 setupMemory(); 3742 Command c = Command("round"); 3743 if (precision) c.setNumber(precision); 3744 tryPut(c); 3745 return this; 3746 } 3747 3748 3749 /++ 3750 3751 Substract two numbers. 3752 3753 Params: 3754 - (number): The second number in a subtraction. 3755 3756 Returns: 3757 - Lodash chained on (number): the difference. 3758 3759 +/ 3760 auto ref subtract(T)(auto ref T other) { 3761 setupMemory(); 3762 Command c = Command("subtract"); 3763 c.setNumber(other); 3764 tryPut(c); 3765 return this; 3766 } 3767 3768 /++ 3769 3770 Computes the sum of the values in array. 3771 3772 Returns: 3773 - Lodash chained on (number): the sum. 3774 3775 +/ 3776 auto ref sum()() { 3777 setupMemory(); 3778 Command c = Command("sum"); 3779 tryPut(c); 3780 return this; 3781 } 3782 3783 /++ 3784 3785 This method is like _.sum except that it accepts iteratee which is invoked 3786 for each element in array to generate the value to be summed. The iteratee 3787 is invoked with one argument: (value). 3788 3789 Params: 3790 - [iteratee=_.identity] (Function): The iteratee invoked per element. 3791 3792 Returns: 3793 - Lodash chained on (number): the sum. 3794 3795 +/ 3796 auto ref sumBy(T = Any)(auto ref T iteratee = T.init) { 3797 setupMemory(); 3798 Command c = Command("sumBy"); 3799 if (iteratee) c.setCallback(iteratee); 3800 tryPut(c); 3801 return this; 3802 } 3803 3804 /++ 3805 3806 Clamps number within the inclusive lower and upper bounds. 3807 3808 Params: 3809 - [lower] (number): The lower bound. 3810 - upper (number): The upper bound. 3811 3812 Returns: 3813 - Lodash chained on (number): the clamped number. 3814 3815 +/ 3816 auto ref clamp(T, U)(auto ref T lower, auto ref U upper) { 3817 setupMemory(); 3818 Command c = Command("clamp"); 3819 c.setNumber(lower); 3820 c.setNumber(upper); 3821 tryPut(c); 3822 return this; 3823 } 3824 3825 /++ 3826 3827 Checks if n is between start and up to, but not including, end. 3828 If end is not specified, it's set to start with start then set to 0. 3829 If start is greater than end the params are swapped to support 3830 negative ranges. 3831 3832 Params: 3833 - [start=0] (number): The start of the range. 3834 - end (number): The end of the range. 3835 3836 Returns: 3837 - Lodash chained on (boolean): true if number is in the range, else false 3838 3839 +/ 3840 auto ref inRange(T, U)(auto ref T start, auto ref U end) { 3841 setupMemory(); 3842 Command c = Command("inRange"); 3843 c.setNumber(start); 3844 c.setNumber(end); 3845 tryPut(c); 3846 return this; 3847 } 3848 3849 auto ref inRange(T)(auto ref T end) { 3850 setupMemory(); 3851 Command c = Command("inRange"); 3852 c.setNumber(end); 3853 tryPut(c); 3854 return this; 3855 } 3856 3857 /++ 3858 3859 Produces a random number between the inclusive lower and upper bounds. 3860 If only one argument is provided a number between 0 and the given number 3861 is returned. If floating is true, or either lower or upper are floats, 3862 a floating-point number is returned instead of an integer. 3863 3864 Note: JavaScript follows the IEEE-754 standard for resolving floating-point 3865 values which can produce unexpected results. 3866 3867 Params: 3868 - chained [lower=0] (number): The lower bound. 3869 - [upper=1] (number): The upper bound. 3870 - [floating] (boolean): Specify returning a floating-point number. 3871 3872 Returns: 3873 - Lodash chained on (number): the random number. 3874 3875 +/ 3876 auto ref random(T)(auto ref T upper, auto ref U floating) { 3877 setupMemory(); 3878 Command c = Command("random"); 3879 c.setNumber(upper); 3880 c.setBoolean(floating); 3881 tryPut(c); 3882 return this; 3883 } 3884 3885 /++ 3886 3887 Assigns own enumerable string keyed properties of source objects to the destination object. Source objects are applied from left to right. Subsequent sources overwrite property assignments of previous sources. 3888 3889 Note: This method mutates object and is loosely based on Object.assign. 3890 3891 Params: 3892 - [sources] (...Object): The source objects. 3893 3894 Returns: 3895 - Lodash chained on (Object): object. 3896 3897 +/ 3898 auto ref assign(ARGS...)(auto ref ARGS sources) { 3899 setupMemory(); 3900 Command c = Command("assign"); 3901 foreach(ref obj; sources) { c.setHandleOrEval(obj); } 3902 tryPut(c); 3903 return this; 3904 } 3905 3906 /++ 3907 3908 This method is like _.assign except that it iterates over own and inherited source properties. 3909 3910 Note: This method mutates object. 3911 3912 Params: 3913 - [sources] (...Object): The source objects. 3914 3915 Returns: 3916 - Lodash chained on (Object): object. 3917 3918 +/ 3919 auto ref assignIn(ARGS...)(auto ref ARGS sources) { 3920 setupMemory(); 3921 Command c = Command("assignIn"); 3922 foreach(ref obj; sources) { c.setHandleOrEval(obj); } 3923 tryPut(c); 3924 return this; 3925 } 3926 /++ 3927 3928 This method is like _.assignIn except that it accepts customizer which is 3929 invoked to produce the assigned values. If customizer returns undefined, assignment 3930 is handled by the method instead. The customizer is invoked with five arguments: 3931 (objValue, srcValue, key, object, source). 3932 3933 Note: This method mutates object. 3934 3935 Params: 3936 - [sources] (...Object): The source objects. 3937 - [customizer] (Function): The function to customize assigned values. 3938 3939 Returns: 3940 - Lodash chained on (Object): object. 3941 3942 +/ 3943 auto ref assignInWith(T, U)(auto ref T sources, auto ref U customizer) { 3944 setupMemory(); 3945 Command c = Command("assignInWith"); 3946 c.setHandleOrEval(sources); 3947 c.setCallback(customizer); 3948 tryPut(c); 3949 return this; 3950 } 3951 /++ 3952 3953 This method is like _.assign except that it accepts customizer which is 3954 invoked to produce the assigned values. If customizer returns undefined, 3955 assignment is handled by the method instead. The customizer is invoked 3956 with five arguments: (objValue, srcValue, key, object, source). 3957 3958 Note: This method mutates object. 3959 3960 Params: 3961 - [sources] (...Object): The source objects. 3962 - [customizer] (Function): The function to customize assigned values. 3963 3964 Returns: 3965 - Lodash chained on (Object): object. 3966 3967 +/ 3968 auto ref assignWith(T, U)(auto ref T sources, auto ref U customizer) { 3969 setupMemory(); 3970 Command c = Command("assignWith"); 3971 c.setHandleOrEval(sources); 3972 c.setCallback(customizer); 3973 tryPut(c); 3974 return this; 3975 } 3976 3977 3978 /++ 3979 3980 Creates an array of values corresponding to paths of object. 3981 3982 Note: This method mutates object. 3983 3984 Params: 3985 - [paths] (...(string|string[])): The property paths to pick. 3986 3987 Returns: 3988 - Lodash chained on (Array): the picked values. 3989 3990 +/ 3991 auto ref at(ARGS...)(auto ref ARGS paths) { 3992 setupMemory(); 3993 Command c = Command("at"); 3994 foreach(ref path; paths) { c.setString(path); } 3995 tryPut(c); 3996 return this; 3997 } 3998 3999 /++ 4000 4001 Creates an object that inherits from the prototype object. If a properties 4002 object is given, its own enumerable string keyed properties are assigned 4003 to the created object. 4004 4005 Params: 4006 - [properties] (Object): The properties to assign to the object. 4007 4008 Returns: 4009 - Lodash chained on (Object): new object. 4010 4011 +/ 4012 auto ref create(T)(auto ref T properties) { 4013 setupMemory(); 4014 Command c = Command("create"); 4015 c.setHandleOrEval(properties); 4016 tryPut(c); 4017 return this; 4018 } 4019 4020 /++ 4021 4022 Assigns own and inherited enumerable string keyed properties of source objects 4023 to the destination object for all destination properties that resolve to 4024 undefined. Source objects are applied from left to right. Once a property is 4025 set, additional values of the same property are ignored. 4026 4027 Note: This method mutates object. 4028 4029 Params: 4030 - [sources] (...Object): The source objects. 4031 4032 Returns: 4033 - Lodash chained on (Object): object. 4034 4035 +/ 4036 auto ref defaults(ARGS...)(auto ref ARGS sources) { 4037 setupMemory(); 4038 Command c = Command("defaults"); 4039 foreach(ref source; sources) c.setHandleOrEval(source); 4040 tryPut(c); 4041 return this; 4042 } 4043 4044 4045 /++ 4046 4047 This method is like _.defaults except that it recursively assigns default properties. 4048 4049 Note: This method mutates object. 4050 4051 Params: 4052 - [sources] (...Object): The source objects. 4053 4054 Returns: 4055 - Lodash chained on (Object): object. 4056 4057 +/ 4058 auto ref defaultsDeep(ARGS...)(auto ref ARGS sources) { 4059 setupMemory(); 4060 Command c = Command("defaultsDeep"); 4061 foreach(ref source; sources) c.setHandleOrEval(source); 4062 tryPut(c); 4063 return this; 4064 } 4065 4066 /++ 4067 4068 This method is like _.find except that it returns the key of the first element 4069 predicate returns truthy for instead of the element itself. 4070 4071 Params: 4072 - [predicate=_.identity] (Function): The function invoked per iteration. 4073 4074 Returns: 4075 - Lodash chained on (*): the key of the matched element, else undefined. 4076 4077 +/ 4078 auto ref findKey(T = Any)(auto ref T predicate = T.init) { 4079 setupMemory(); 4080 Command c = Command("findKey"); 4081 if (predicate) c.setCallback(predicate); 4082 tryPut(c); 4083 return this; 4084 } 4085 4086 4087 /++ 4088 4089 This method is like _.findKey except that it iterates over elements of a 4090 collection in the opposite order. 4091 4092 Params: 4093 - [predicate=_.identity] (Function): The function invoked per iteration. 4094 4095 Returns: 4096 - Lodash chained on (*): the key of the matched element, else undefined. 4097 4098 +/ 4099 auto ref findLastKey(T = Any)(auto ref T predicate = T.init) { 4100 setupMemory(); 4101 Command c = Command("findLastKey"); 4102 if (predicate) c.setCallback(predicate); 4103 tryPut(c); 4104 return this; 4105 } 4106 4107 /++ 4108 4109 This method is like _.findKey except that it iterates over elements of a 4110 collection in the opposite order. 4111 4112 Params: 4113 - [iteratee=_.identity] (Function): The function invoked per iteration. 4114 4115 Returns: 4116 - Lodash chained on (Object): object. 4117 4118 +/ 4119 auto ref forIn(T = Any)(auto ref T iteratee = T.init) { 4120 setupMemory(); 4121 Command c = Command("forIn"); 4122 if (iteratee) c.setCallback(iteratee); 4123 tryPut(c); 4124 return this; 4125 } 4126 4127 /++ 4128 4129 This method is like _.forIn except that it iterates over properties of object in 4130 the opposite order. 4131 4132 Params: 4133 - [iteratee=_.identity] (Function): The function invoked per iteration. 4134 4135 Returns: 4136 - Lodash chained on (Object): object. 4137 4138 +/ 4139 auto ref forInRight(T = Any)(auto ref T iteratee = T.init) { 4140 setupMemory(); 4141 Command c = Command("forInRight"); 4142 if (iteratee) c.setCallback(iteratee); 4143 tryPut(c); 4144 return this; 4145 } 4146 4147 /++ 4148 4149 Iterates over own enumerable string keyed properties of an object and invokes 4150 iteratee for each property. The iteratee is invoked with three arguments: (value, key, object). 4151 Iteratee functions may exit iteration early by explicitly returning false. 4152 4153 Params: 4154 - [iteratee=_.identity] (Function): The function invoked per iteration. 4155 4156 Returns: 4157 - Lodash chained on (Object): object. 4158 4159 +/ 4160 auto ref forOwn(T = Any)(auto ref T iteratee = T.init) { 4161 setupMemory(); 4162 Command c = Command("forOwn"); 4163 if (iteratee) c.setCallback(iteratee); 4164 tryPut(c); 4165 return this; 4166 } 4167 4168 4169 /++ 4170 4171 This method is like _.forOwn except that it iterates over properties of object in the opposite order. 4172 4173 Params: 4174 - [iteratee=_.identity] (Function): The function invoked per iteration. 4175 4176 Returns: 4177 - Lodash chained on (Object): object. 4178 4179 +/ 4180 auto ref forOwnRight(T = Any)(auto ref T iteratee = T.init) { 4181 setupMemory(); 4182 Command c = Command("forOwnRight"); 4183 if (iteratee) c.setCallback(iteratee); 4184 tryPut(c); 4185 return this; 4186 } 4187 4188 4189 /++ 4190 4191 Creates an array of function property names from own enumerable properties of object. 4192 4193 Returns: 4194 - Lodash chained on (Array): the function names. 4195 4196 +/ 4197 auto ref functions()() { 4198 setupMemory(); 4199 Command c = Command("functions"); 4200 tryPut(c); 4201 return this; 4202 } 4203 4204 4205 /++ 4206 4207 Creates an array of function property names from own and inherited enumerable properties of object. 4208 4209 Returns: 4210 - Lodash chained on (Array): the function names. 4211 4212 +/ 4213 auto ref functionsIn()() { 4214 setupMemory(); 4215 Command c = Command("functionsIn"); 4216 tryPut(c); 4217 return this; 4218 } 4219 4220 4221 /++ 4222 4223 Creates an array of function property names from own and inherited enumerable properties of object. 4224 4225 Params: 4226 - path (Array|string): The path of the property to get. 4227 - [defaultValue] (*): The value returned for undefined resolved values. 4228 4229 Returns: 4230 - Lodash chained on (*): the resolved value. 4231 4232 +/ 4233 auto ref get(T, U = Any)(auto ref T path, auto ref U defaultValue = U.init) { 4234 setupMemory(); 4235 Command c = Command("get"); 4236 c.setString(path); 4237 if (defaultValue) c.setAnyValue(defaultValue); 4238 tryPut(c); 4239 return this; 4240 } 4241 4242 /++ 4243 4244 Checks if path is a direct property of object. 4245 4246 Params: 4247 - path (Array|string): The path to check. 4248 4249 Returns: 4250 - Lodash chained on (boolean): true if path exists, else false. 4251 4252 +/ 4253 auto ref has(T)(auto ref T path) { 4254 setupMemory(); 4255 Command c = Command("has"); 4256 c.setString(path); 4257 tryPut(c); 4258 return this; 4259 } 4260 /++ 4261 4262 Checks if path is a direct or inherited property of object. 4263 4264 Params: 4265 - path (Array|string): The path to check. 4266 4267 Returns: 4268 - Lodash chained on (boolean): true if path exists, else false. 4269 4270 +/ 4271 auto ref hasIn(T)(auto ref T path) { 4272 setupMemory(); 4273 Command c = Command("hasIn"); 4274 c.setString(path); 4275 tryPut(c); 4276 return this; 4277 } 4278 4279 /++ 4280 4281 Creates an object composed of the inverted keys and values of object. 4282 If object contains duplicate values, subsequent values overwrite property 4283 assignments of previous values. 4284 4285 Params: 4286 - path (Array|string): The path to check. 4287 4288 Returns: 4289 - Lodash chained on (Object): the new inverted object. 4290 4291 +/ 4292 auto ref invert()() { 4293 setupMemory(); 4294 Command c = Command("invert"); 4295 tryPut(c); 4296 return this; 4297 } 4298 4299 4300 /++ 4301 4302 This method is like _.invert except that the inverted object is generated from 4303 the results of running each element of object thru iteratee. The corresponding 4304 inverted value of each inverted key is an array of keys responsible for generating 4305 the inverted value. The iteratee is invoked with one argument: (value). 4306 4307 Params: 4308 - [iteratee=_.identity] (Function): The iteratee invoked per element. 4309 4310 Returns: 4311 - Lodash chained on (Object): the new inverted object. 4312 4313 +/ 4314 auto ref invertBy(T = Any)(auto ref T iteratee = T.init) { 4315 setupMemory(); 4316 Command c = Command("invertBy"); 4317 if (iteratee) c.setCallback(iteratee); 4318 tryPut(c); 4319 return this; 4320 } 4321 4322 /++ 4323 4324 Invokes the method at path of object. 4325 4326 Params: 4327 - path (Array|string): The path of the method to invoke. 4328 - [args] (...*): The arguments to invoke the method with. 4329 4330 Returns: 4331 - Lodash chained on (*): the result of the invoked method. 4332 4333 +/ 4334 auto ref invoke(T, ARGS...)(auto ref T path, auto ref ARGS args) { 4335 setupMemory(); 4336 Command c = Command("invoke"); 4337 c.setString(path); 4338 foreach (ref arg; args) c.setAnyValue(arg); 4339 tryPut(c); 4340 return this; 4341 } 4342 4343 /++ 4344 4345 Creates an array of the own enumerable property names of object. 4346 4347 Note: Non-object values are coerced to objects. See the ES spec for more details. 4348 4349 Params: 4350 - path (Array|string): The path to check. 4351 4352 Returns: 4353 - Lodash chained on (Array): the array of property names. 4354 4355 +/ 4356 auto ref keys()() { 4357 setupMemory(); 4358 Command c = Command("keys"); 4359 tryPut(c); 4360 return this; 4361 } 4362 4363 4364 /++ 4365 4366 Creates an array of the own and inherited enumerable property names of object. 4367 4368 Note: Non-object values are coerced to objects. 4369 4370 Params: 4371 - path (Array|string): The path to check. 4372 4373 Returns: 4374 - Lodash chained on (Array): the array of property names. 4375 4376 +/ 4377 auto ref keysIn()() { 4378 setupMemory(); 4379 Command c = Command("keysIn"); 4380 tryPut(c); 4381 return this; 4382 } 4383 4384 4385 /++ 4386 The opposite of _.mapValues; this method creates an object with the same 4387 values as object and keys generated by running each own enumerable string 4388 keyed property of object thru iteratee. The iteratee is invoked with three 4389 arguments: (value, key, object). 4390 4391 Params: 4392 - [iteratee=_.identity] (Function): The function invoked per iteration. 4393 4394 Returns: 4395 - Lodash chained on (Object): the new mapped object. 4396 4397 +/ 4398 auto ref mapKeys(T = Any)(auto ref T iteratee = T.init) { 4399 setupMemory(); 4400 Command c = Command("mapKeys"); 4401 if (iteratee) c.setCallback(iteratee); 4402 tryPut(c); 4403 return this; 4404 } 4405 /++ 4406 Creates an object with the same keys as object and values generated by running each own 4407 enumerable string keyed property of object thru iteratee. The iteratee is invoked 4408 with three arguments: (value, key, object). 4409 4410 Params: 4411 - [iteratee=_.identity] (Function): The function invoked per iteration. 4412 4413 Returns: 4414 - Lodash chained on (Object): the new mapped object. 4415 4416 +/ 4417 auto ref mapValues(T = Any)(auto ref T iteratee = T.init) { 4418 setupMemory(); 4419 Command c = Command("mapValues"); 4420 if (iteratee) c.setCallback(iteratee); 4421 tryPut(c); 4422 return this; 4423 } 4424 4425 /++ 4426 This method is like _.assign except that it recursively merges own and inherited 4427 enumerable string keyed properties of source objects into the destination object. 4428 Source properties that resolve to undefined are skipped if a destination value 4429 exists. Array and plain object properties are merged recursively. Other objects 4430 and value types are overridden by assignment. Source objects are applied from 4431 left to right. Subsequent sources overwrite property assignments of previous sources. 4432 4433 Note: This method mutates object. 4434 4435 Params: 4436 - [sources] (...Object): The source objects. 4437 4438 Returns: 4439 - Lodash chained on (Object): object. 4440 4441 +/ 4442 auto ref merge(ARGS...)(auto ref ARGS args) { 4443 setupMemory(); 4444 Command c = Command("merge"); 4445 foreach (ref arg; args) c.setHandleOrEval(arg); 4446 tryPut(c); 4447 return this; 4448 } 4449 4450 /++ 4451 This method is like _.merge except that it accepts customizer which 4452 is invoked to produce the merged values of the destination and source 4453 properties. If customizer returns undefined, merging is handled by 4454 the method instead. The customizer is invoked with six arguments: 4455 (objValue, srcValue, key, object, source, stack). 4456 4457 Note: This method mutates object. 4458 4459 Params: 4460 - [sources] (...Object): The source objects. 4461 - customizer (Function): The function to customize assigned values. 4462 4463 Returns: 4464 - Lodash chained on (Object): object. 4465 4466 +/ 4467 auto ref mergeWith(T, U)(auto ref T source, auto ref T customizer) { 4468 setupMemory(); 4469 Command c = Command("mergeWith"); 4470 c.setHandleOrEval(source); 4471 c.setCallback(customizer); 4472 tryPut(c); 4473 return this; 4474 } 4475 4476 /++ 4477 The opposite of _.pick; this method creates an object composed of the own and 4478 inherited enumerable property paths of object that are not omitted. 4479 4480 Note: This method is considerably slower than _.pick. 4481 4482 Params: 4483 - [paths] (...(string|string[])): The property paths to omit. 4484 4485 Returns: 4486 - Lodash chained on (Object): the new object. 4487 4488 +/ 4489 auto ref omit(ARGS...)(auto ref ARGS paths) { 4490 setupMemory(); 4491 Command c = Command("omit"); 4492 foreach (ref path; paths) c.setString(path); 4493 tryPut(c); 4494 return this; 4495 } 4496 4497 /++ 4498 The opposite of _.pickBy; this method creates an object composed of the own 4499 and inherited enumerable string keyed properties of object that predicate 4500 doesn't return truthy for. The predicate is invoked with two arguments: (value, key). 4501 4502 Params: 4503 - [predicate=_.identity] (Function): The function invoked per property. 4504 4505 Returns: 4506 - Lodash chained on (Object): the new object. 4507 4508 +/ 4509 auto ref omitBy(T = Any)(auto ref T iteratee = T.init) { 4510 setupMemory(); 4511 Command c = Command("omitBy"); 4512 if (iteratee) c.setCallback(iteratee); 4513 tryPut(c); 4514 return this; 4515 } 4516 4517 4518 /++ 4519 4520 Creates an object composed of the picked object properties. 4521 4522 Note: This method mutates object. 4523 4524 Params: 4525 - [paths] (...(string|string[])): The property paths to pick. 4526 4527 Returns: 4528 - Lodash chained on (Object): the new object. 4529 4530 +/ 4531 auto ref pick(ARGS...)(auto ref ARGS paths) { 4532 setupMemory(); 4533 Command c = Command("pick"); 4534 foreach(ref path; paths) { c.setString(path); } 4535 tryPut(c); 4536 return this; 4537 } 4538 4539 4540 /++ 4541 Creates an object composed of the object properties predicate returns 4542 truthy for. The predicate is invoked with two arguments: (value, key). 4543 4544 Params: 4545 - [predicate=_.identity] (Function): The function invoked per property. 4546 4547 Returns: 4548 - Lodash chained on (Object): the new object. 4549 4550 +/ 4551 auto ref pickBy(T = Any)(auto ref T iteratee = T.init) { 4552 setupMemory(); 4553 Command c = Command("pickBy"); 4554 if (iteratee) c.setCallback(iteratee); 4555 tryPut(c); 4556 return this; 4557 } 4558 4559 4560 /++ 4561 4562 This method is like _.get except that if the resolved value is a function 4563 it's invoked with the this binding of its parent object and its result 4564 is returned. 4565 4566 Params: 4567 - path (Array|string): The path of the property to resolve. 4568 - [defaultValue] (*): The value returned for undefined resolved values. 4569 4570 Returns: 4571 - Lodash chained on (*): the resolved value. 4572 4573 +/ 4574 auto ref result(T, U)(auto ref T path, auto ref U defaultValue) { 4575 setupMemory(); 4576 Command c = Command("result"); 4577 c.setString(path); 4578 c.setAnyValue(defaultValue); 4579 tryPut(c); 4580 return this; 4581 } 4582 /++ 4583 4584 Sets the value at path of object. If a portion of path doesn't exist, 4585 it's created. Arrays are created for missing index properties while 4586 objects are created for all other missing properties. Use _.setWith 4587 to customize path creation. 4588 4589 Note: This method mutates object. 4590 4591 Params: 4592 - path (Array|string): The path of the property to set. 4593 - value (*): The value to set. 4594 4595 Returns: 4596 - Lodash chained on (Object): object. 4597 4598 +/ 4599 auto ref set(T, U)(auto ref T path, auto ref U value) { 4600 setupMemory(); 4601 Command c = Command("set"); 4602 c.setString(path); 4603 c.setAnyValue(value); 4604 tryPut(c); 4605 return this; 4606 } 4607 4608 /++ 4609 4610 This method is like _.set except that it accepts customizer which is 4611 invoked to produce the objects of path. If customizer returns undefined 4612 path creation is handled by the method instead. The customizer is 4613 invoked with three arguments: (nsValue, key, nsObject). 4614 4615 Note: This method mutates object. 4616 4617 Params: 4618 - path (Array|string): The path of the property to set. 4619 - value (*): The value to set. 4620 - [customizer] (Function): The function to customize assigned values. 4621 4622 Returns: 4623 - Lodash chained on (Object): object. 4624 4625 +/ 4626 auto ref set(T, U, V)(auto ref T path, auto ref U value, auto ref V customizer) { 4627 setupMemory(); 4628 Command c = Command("set"); 4629 c.setString(path); 4630 c.setAnyValue(value); 4631 c.setCallback(customizer); 4632 tryPut(c); 4633 return this; 4634 } 4635 4636 4637 4638 /++ 4639 4640 Creates an array of own enumerable string keyed-value pairs for object 4641 which can be consumed by _.fromPairs. If object is a map or set, its 4642 entries are returned. 4643 4644 Returns: 4645 - Lodash chained on (Array): the key-value pairs. 4646 4647 +/ 4648 auto ref toPairs()() { 4649 setupMemory(); 4650 Command c = Command("toPairs"); 4651 tryPut(c); 4652 return this; 4653 } 4654 4655 /++ 4656 4657 Creates an array of own and inherited enumerable string keyed-value pairs 4658 for object which can be consumed by _.fromPairs. If object is a map or 4659 set, its entries are returned. 4660 4661 Returns: 4662 - Lodash chained on (Array): the key-value pairs. 4663 4664 +/ 4665 auto ref toPairsIn()() { 4666 setupMemory(); 4667 Command c = Command("toPairsIn"); 4668 tryPut(c); 4669 return this; 4670 } 4671 4672 /++ 4673 An alternative to _.reduce; this method transforms object to a new 4674 accumulator object which is the result of running each of its own 4675 enumerable string keyed properties thru iteratee, with each invocation 4676 potentially mutating the accumulator object. If accumulator is not 4677 provided, a new object with the same [[Prototype]] will be used. The 4678 iteratee is invoked with four arguments: (accumulator, value, key, object). 4679 Iteratee functions may exit iteration early by explicitly returning false. 4680 4681 Params: 4682 - [predicate=_.identity] (Function): The function invoked per property. 4683 - [accumulator] (*): The custom accumulator value. 4684 4685 Returns: 4686 - Lodash chained on (*): the accumulated value. 4687 4688 +/ 4689 auto ref transform(T, U)(auto ref T iteratee, auto ref U accumulator) { 4690 setupMemory(); 4691 Command c = Command("transform"); 4692 c.setCallback(iteratee); 4693 c.setAnyValue(accumulator); 4694 tryPut(c); 4695 return this; 4696 } 4697 4698 /++ 4699 4700 Removes the property at path of object. 4701 4702 Params: 4703 - path (Array|string): The path of the property to unset. 4704 4705 Returns: 4706 - Lodash chained on (boolean): true if the property is deleted, else false. 4707 4708 +/ 4709 auto ref unset(T)(auto ref T path) { 4710 setupMemory(); 4711 Command c = Command("unset"); 4712 c.setString(path); 4713 tryPut(c); 4714 return this; 4715 } 4716 4717 /++ 4718 4719 This method is like _.set except that accepts updater to produce the 4720 value to set. Use _.updateWith to customize path creation. The updater 4721 is invoked with one argument: (value). 4722 4723 Note: This method mutates object. 4724 4725 Params: 4726 - path (Array|string): The path of the property to unset. 4727 - updater (Function): The function to produce the updated value. 4728 4729 Returns: 4730 - Lodash chained on (Object): object. 4731 4732 +/ 4733 auto ref update(T, U)(auto ref T path, auto ref U updater) { 4734 setupMemory(); 4735 Command c = Command("update"); 4736 c.setString(path); 4737 c.setCallback(updater); 4738 tryPut(c); 4739 return this; 4740 } 4741 4742 4743 /++ 4744 4745 This method is like _.update except that it accepts customizer which 4746 is invoked to produce the objects of path. If customizer returns 4747 undefined path creation is handled by the method instead. The customizer 4748 is invoked with three arguments: (nsValue, key, nsObject). 4749 4750 Note: This method mutates object. 4751 4752 Params: 4753 - path (Array|string): The path of the property to unset. 4754 - updater (Function): The function to produce the updated value. 4755 - [customizer] (Function): The function to customize assigned values. 4756 4757 Returns: 4758 - Lodash chained on (Object): object. 4759 4760 +/ 4761 auto ref updateWith(T, U)(auto ref T path, auto ref U updater) { 4762 setupMemory(); 4763 Command c = Command("updateWith"); 4764 c.setString(path); 4765 c.setCallback(updater); 4766 tryPut(c); 4767 return this; 4768 } 4769 4770 /++ 4771 4772 Creates an array of the own enumerable string keyed property values of object. 4773 4774 Note: Non-object values are coerced to objects. 4775 4776 Returns: 4777 - Lodash chained on (Array): the array of property values. 4778 4779 +/ 4780 auto ref values()() { 4781 setupMemory(); 4782 Command c = Command("values"); 4783 tryPut(c); 4784 return this; 4785 } 4786 4787 4788 /++ 4789 4790 Creates an array of the own and inherited enumerable string keyed property 4791 values of object. 4792 4793 Note: Non-object values are coerced to objects 4794 4795 Returns: 4796 - Lodash chained on (Array): the array of property values. 4797 4798 +/ 4799 auto ref valuesIn()() { 4800 setupMemory(); 4801 Command c = Command("valuesIn"); 4802 tryPut(c); 4803 return this; 4804 } 4805 4806 /++ 4807 4808 Converts string to camel case. 4809 4810 Returns: 4811 - Lodash chained on (string): the camel cased string. 4812 4813 +/ 4814 auto ref camelCase()() { 4815 setupMemory(); 4816 Command c = Command("camelCase"); 4817 tryPut(c); 4818 return this; 4819 } 4820 4821 /++ 4822 4823 Converts the first character of string to upper case and the 4824 remaining to lower case. 4825 4826 Returns: 4827 - Lodash chained on (string): the capitalized string. 4828 4829 +/ 4830 auto ref capitalize()() { 4831 setupMemory(); 4832 Command c = Command("capitalize"); 4833 tryPut(c); 4834 return this; 4835 } 4836 /++ 4837 4838 Deburrs string by converting Latin-1 Supplement and Latin 4839 Extended-A letters to basic Latin letters and removing combining 4840 diacritical marks. 4841 4842 Returns: 4843 - Lodash chained on (string): the deburred string. 4844 4845 +/ 4846 auto ref deburr()() { 4847 setupMemory(); 4848 Command c = Command("deburr"); 4849 tryPut(c); 4850 return this; 4851 } 4852 4853 /++ 4854 4855 Checks if string ends with the given target string. 4856 4857 Params: 4858 - [target] (string): The string to search for. 4859 - [position=string.length] (number): The position to search up to. 4860 4861 Returns: 4862 - Lodash chained on (boolean): true if string ends with target, else false. 4863 4864 +/ 4865 auto ref endsWith(T, U = Any)(auto ref T target, auto ref U position = U.init) { 4866 setupMemory(); 4867 Command c = Command("endsWith"); 4868 c.setString(target); 4869 if (position) c.setNumber(position); 4870 tryPut(c); 4871 return this; 4872 } 4873 4874 4875 /++ 4876 4877 Converts the characters "&", "<", ">", '"', and "'" in string to their 4878 corresponding HTML entities. 4879 4880 Note: No other characters are escaped. To escape additional characters 4881 use a third-party library like he. 4882 4883 Though the ">" character is escaped for symmetry, characters like ">" 4884 and "/" don't need escaping in HTML and have no special meaning unless 4885 they're part of a tag or unquoted attribute value. See Mathias Bynens's 4886 article (under "semi-related fun fact") for more details. 4887 4888 When working with HTML you should always quote attribute values to 4889 reduce XSS vectors. 4890 4891 Returns: 4892 - Lodash chained on (string): the escaped string. 4893 4894 +/ 4895 auto ref escape()() { 4896 setupMemory(); 4897 Command c = Command("escape"); 4898 tryPut(c); 4899 return this; 4900 } 4901 4902 4903 /++ 4904 4905 Escapes the RegExp special characters "^", "$", "", ".", "*", "+", "?", 4906 "(", ")", "[", "]", "{", "}", and "|" in string. 4907 4908 Returns: 4909 - Lodash chained on (string): the escaped string. 4910 4911 +/ 4912 auto ref escapeRegExp()() { 4913 setupMemory(); 4914 Command c = Command("escapeRegExp"); 4915 tryPut(c); 4916 return this; 4917 } 4918 4919 /++ 4920 4921 Converts string to kebab case. 4922 4923 Returns: 4924 - Lodash chained on (string): the kebab cased string. 4925 4926 +/ 4927 auto ref kebabCase()() { 4928 setupMemory(); 4929 Command c = Command("kebabCase"); 4930 tryPut(c); 4931 return this; 4932 } 4933 4934 /++ 4935 4936 Converts string, as space separated words, to lower case. 4937 4938 Returns: 4939 - Lodash chained on (string): the lower cased string. 4940 4941 +/ 4942 auto ref lowerCase()() { 4943 setupMemory(); 4944 Command c = Command("lowerCase"); 4945 tryPut(c); 4946 return this; 4947 } 4948 4949 /++ 4950 4951 Converts the first character of string to lower case. 4952 4953 Returns: 4954 - Lodash chained on (string): the converted string. 4955 4956 +/ 4957 auto ref lowerFirst()() { 4958 setupMemory(); 4959 Command c = Command("lowerFirst"); 4960 tryPut(c); 4961 return this; 4962 } 4963 4964 /++ 4965 4966 Pads string on the left and right sides if it's shorter than length. 4967 Padding characters are truncated if they can't be evenly divided by length. 4968 4969 Params: 4970 - [length=0] (number): The padding length. 4971 - [chars=' '] (string): The string used as padding. 4972 4973 Returns: 4974 - Lodash chained on (string): the padded string. 4975 4976 +/ 4977 auto ref pad(T = Any, U = Any)(auto ref T length = T.init, auto ref U chars = U.init) { 4978 setupMemory(); 4979 Command c = Command("pad"); 4980 if (length) c.setNumber(length); 4981 if (chars) c.setString(chars); 4982 tryPut(c); 4983 return this; 4984 } 4985 4986 4987 /++ 4988 4989 Pads string on the right side if it's shorter than length. 4990 Padding characters are truncated if they exceed length. 4991 4992 Params: 4993 - [length=0] (number): The padding length. 4994 - [chars=' '] (string): The string used as padding. 4995 4996 Returns: 4997 - Lodash chained on (string): the padded string. 4998 4999 +/ 5000 auto ref padEnd(T = Any, U = Any)(auto ref T length = T.init, auto ref U chars = U.init) { 5001 setupMemory(); 5002 Command c = Command("padEnd"); 5003 if (length) c.setNumber(length); 5004 if (chars) c.setString(chars); 5005 tryPut(c); 5006 return this; 5007 } 5008 5009 /++ 5010 5011 Pads string on the left side if it's shorter than length. Padding 5012 characters are truncated if they exceed length. 5013 5014 Params: 5015 - [length=0] (number): The padding length. 5016 - [chars=' '] (string): The string used as padding. 5017 5018 Returns: 5019 - Lodash chained on (string): the padded string. 5020 5021 +/ 5022 auto ref padStart(T = Any, U = Any)(auto ref T length = T.init, auto ref U chars = U.init) { 5023 setupMemory(); 5024 Command c = Command("padStart"); 5025 if (length) c.setNumber(length); 5026 if (chars) c.setString(chars); 5027 tryPut(c); 5028 return this; 5029 } 5030 5031 /++ 5032 5033 Converts string to an integer of the specified radix. If radix is undefined 5034 or 0, a radix of 10 is used unless value is a hexadecimal, in which case a 5035 radix of 16 is used. 5036 5037 Note: This method aligns with the ES5 implementation of parseInt. 5038 5039 Params: 5040 - [radix=10] (number): The radix to interpret value by. 5041 5042 Returns: 5043 - Lodash chained on (number): the converted integer. 5044 5045 +/ 5046 auto ref parseInt(T = Any)(auto ref T radix = T.init) { 5047 setupMemory(); 5048 Command c = Command("parseInt"); 5049 if (radix) c.setNumber(radix); 5050 tryPut(c); 5051 return this; 5052 } 5053 5054 /++ 5055 5056 Repeats the given string n times. 5057 5058 Params: 5059 - [n=1] (number): The number of times to repeat the string. 5060 5061 Returns: 5062 - Lodash chained on (string): the repeated string. 5063 5064 +/ 5065 auto ref repeat(T = Any)(auto ref T radix = T.init) { 5066 setupMemory(); 5067 Command c = Command("repeat"); 5068 if (n) c.setNumber(n); 5069 tryPut(c); 5070 return this; 5071 } 5072 /++ 5073 5074 Replaces matches for pattern in string with replacement. 5075 5076 Note: This method is based on String#replace. 5077 5078 Params: 5079 - pattern (RegExp|string): The pattern to replace. 5080 - replacement (Function|string): The match replacement. 5081 5082 Returns: 5083 - Lodash chained on (string): the modified string. 5084 5085 +/ 5086 auto ref replace(T, U)(auto ref T pattern, auto ref U replacement) { 5087 setupMemory(); 5088 Command c = Command("replace"); 5089 if (pattern) c.setNumber(pattern); 5090 if (replacement) c.setNumber(replacement); 5091 tryPut(c); 5092 return this; 5093 } 5094 5095 5096 /++ 5097 5098 Converts string to snake case. 5099 5100 Returns: 5101 - Lodash chained on (string): the snake cased string. 5102 5103 +/ 5104 auto ref snakeCase()() { 5105 setupMemory(); 5106 Command c = Command("snakeCase"); 5107 tryPut(c); 5108 return this; 5109 } 5110 5111 /++ 5112 5113 Splits string by separator. 5114 5115 Params: 5116 - separator (RegExp|string): The separator pattern to split by. 5117 - [limit] (number): The length to truncate results to. 5118 5119 Returns: 5120 - Lodash chained on (Array): the string segments. 5121 5122 +/ 5123 auto ref split(T, U)(auto ref T separator, auto ref U limit) { 5124 setupMemory(); 5125 Command c = Command("split"); 5126 if (separator) c.setString(separator); 5127 if (limit) c.setNumber(limit); 5128 tryPut(c); 5129 return this; 5130 } 5131 5132 5133 /++ 5134 5135 Converts string to start case. 5136 5137 Returns: 5138 - Lodash chained on (string): the start cased string. 5139 5140 +/ 5141 auto ref startCase()() { 5142 setupMemory(); 5143 Command c = Command("startCase"); 5144 tryPut(c); 5145 return this; 5146 } 5147 5148 5149 /++ 5150 5151 Splits string by separator. 5152 5153 Params: 5154 - [target] (string): The string to search for. 5155 - [position=0] (number): The position to search from. 5156 5157 Returns: 5158 - Lodash chained on (boolean): true if string starts with target, else false. 5159 5160 +/ 5161 auto ref startsWith(T, U = Any)(auto ref T target, auto ref U position = U.init) { 5162 setupMemory(); 5163 Command c = Command("startsWith"); 5164 c.setString(target); 5165 if (position) c.setNumber(position); 5166 tryPut(c); 5167 return this; 5168 } 5169 5170 /++ 5171 5172 Creates a compiled template function that can interpolate data properties 5173 in "interpolate" delimiters, HTML-escape interpolated data properties in 5174 "escape" delimiters, and execute JavaScript in "evaluate" delimiters. 5175 Data properties may be accessed as free variables in the template. If a 5176 setting object is given, it takes precedence over _.templateSettings values. 5177 5178 Note: In the development build _.template utilizes sourceURLs for easier 5179 debugging. 5180 5181 For more information on precompiling templates see lodash's custom builds 5182 documentation. 5183 5184 For more information on Chrome extension sandboxes see Chrome's extensions 5185 documentation. 5186 5187 Params: 5188 - [options={}] (Object): The options object. 5189 - [options.escape=_.templateSettings.escape] (RegExp): The HTML "escape" delimiter. 5190 - [options.evaluate=_.templateSettings.evaluate] (RegExp): The "evaluate" delimiter. 5191 - [options.imports=_.templateSettings.imports] (Object): An object to import into the template as free variables. 5192 - [options.interpolate=_.templateSettings.interpolate] (RegExp): The "interpolate" delimiter. 5193 - [options.sourceURL='lodash.templateSources[n]'] (string): The sourceURL of the compiled template. 5194 - [options.variable='obj'] (string): The data object variable name. 5195 5196 Returns: 5197 - Lodash chained on (Function): the compiled template function. 5198 5199 +/ 5200 auto ref template_(T = Any)(auto ref T options = T.init) { 5201 setupMemory(); 5202 Command c = Command("template"); 5203 if (options) c.setHandleOrEval(options); 5204 tryPut(c); 5205 return this; 5206 } 5207 5208 /++ 5209 5210 Attempts to invoke func, returning either the result or the caught error object. 5211 Any additional arguments are provided to func when it's invoked. 5212 5213 Returns: 5214 - Lodash chained on (*): the func result or error object. 5215 5216 +/ 5217 auto ref attempt(ARGS...)(auto ref ARGS args) { 5218 setupMemory(); 5219 Command c = Command("attempt"); 5220 foreach(ref arg; args) c.setAnyValue(arg); 5221 tryPut(c); 5222 return this; 5223 } 5224 5225 /++ 5226 5227 Converts string, as a whole, to lower case just like String#toLowerCase. 5228 5229 Returns: 5230 - Lodash chained on (string): the lower cased string. 5231 5232 +/ 5233 auto ref toLower()() { 5234 setupMemory(); 5235 Command c = Command("toLower"); 5236 tryPut(c); 5237 return this; 5238 } 5239 5240 5241 /++ 5242 5243 Converts string, as a whole, to upper case just like String#toUpperCase. 5244 5245 Returns: 5246 - Lodash chained on (string): the upper cased string. 5247 5248 +/ 5249 auto ref toUpper()() { 5250 setupMemory(); 5251 Command c = Command("toUpper"); 5252 tryPut(c); 5253 return this; 5254 } 5255 5256 /++ 5257 5258 Removes leading and trailing whitespace or specified characters from string. 5259 5260 Params: 5261 - [chars=whitespace] (string): The characters to trim. 5262 5263 Returns: 5264 - Lodash chained on (string): the trimmed string. 5265 5266 +/ 5267 auto ref trim(T = Any)(auto ref T chars = T.init) { 5268 setupMemory(); 5269 Command c = Command("trim"); 5270 if (chars) c.setString(chars); 5271 tryPut(c); 5272 return this; 5273 } 5274 5275 /++ 5276 5277 Removes trailing whitespace or specified characters from string. 5278 5279 Params: 5280 - [chars=whitespace] (string): The characters to trim. 5281 5282 Returns: 5283 - Lodash chained on (string): the trimmed string. 5284 5285 +/ 5286 auto ref trimEnd(T = Any)(auto ref T chars = T.init) { 5287 setupMemory(); 5288 Command c = Command("trimEnd"); 5289 if (chars) c.setString(chars); 5290 tryPut(c); 5291 return this; 5292 } 5293 5294 /++ 5295 5296 Removes leading whitespace or specified characters from string. 5297 5298 Params: 5299 - [chars=whitespace] (string): The characters to trim. 5300 5301 Returns: 5302 - Lodash chained on (string): the trimmed string. 5303 5304 +/ 5305 auto ref trimStart(T = Any)(auto ref T chars = T.init) { 5306 setupMemory(); 5307 Command c = Command("trimStart"); 5308 if (chars) c.setString(chars); 5309 tryPut(c); 5310 return this; 5311 } 5312 5313 /++ 5314 5315 Truncates string if it's longer than the given maximum string length. 5316 The last characters of the truncated string are replaced with the omission 5317 string which defaults to "...". 5318 5319 Params: 5320 - [options={}] (Object): The options object. 5321 - [options.length=30] (number): The maximum string length. 5322 - [options.omission='...'] (string): The string to indicate text is omitted. 5323 - [options.separator] (RegExp|string): The separator pattern to truncate to. 5324 5325 Returns: 5326 - Lodash chained on (string): the truncated string. 5327 5328 +/ 5329 auto ref truncate(T = Any)(auto ref T options = T.init) { 5330 setupMemory(); 5331 Command c = Command("truncate"); 5332 if (options) c.setHandleOrEval(options); 5333 tryPut(c); 5334 return this; 5335 } 5336 5337 5338 /++ 5339 5340 The inverse of _.escape; this method converts the HTML entities 5341 &, <, >, ", and ' in string to their corresponding 5342 characters. 5343 5344 Note: No other HTML entities are unescaped. To unescape additional HTML 5345 entities use a third-party library like he. 5346 5347 Returns: 5348 - Lodash chained on (string): the unescaped string. 5349 5350 +/ 5351 auto ref unescape()() { 5352 setupMemory(); 5353 Command c = Command("unescape"); 5354 tryPut(c); 5355 return this; 5356 } 5357 5358 5359 /++ 5360 5361 Converts string, as space separated words, to upper case. 5362 5363 Returns: 5364 - Lodash chained on (string): the upper cased string. 5365 5366 +/ 5367 auto ref upperCase()() { 5368 setupMemory(); 5369 Command c = Command("upperCase"); 5370 tryPut(c); 5371 return this; 5372 } 5373 5374 /++ 5375 5376 Converts the first character of string to upper case. 5377 5378 Returns: 5379 - Lodash chained on (string): the upper cased string. 5380 5381 +/ 5382 auto ref upperFirst()() { 5383 setupMemory(); 5384 Command c = Command("upperFirst"); 5385 tryPut(c); 5386 return this; 5387 } 5388 5389 /++ 5390 5391 Splits string into an array of its words. 5392 5393 Params: 5394 - [pattern] (RegExp|string): The pattern to match words. 5395 5396 Returns: 5397 - Lodash chained on (Array): the words of string. 5398 5399 +/ 5400 auto ref words(T = Any)(auto ref T pattern = T.init) { 5401 setupMemory(); 5402 Command c = Command("words"); 5403 if (pattern) c.setString(pattern); 5404 tryPut(c); 5405 return this; 5406 } 5407 5408 /++ 5409 5410 Generates a unique ID. If prefix is given, the ID is appended to it. 5411 5412 Params: 5413 - Chained => [prefix=''] (string): The value to prefix the ID with. 5414 5415 Returns: 5416 - Lodash chained on (string): the unique ID. 5417 5418 +/ 5419 auto ref uniqueId()() { 5420 setupMemory(); 5421 Command c = Command("uniqueId"); 5422 tryPut(c); 5423 return this; 5424 } 5425 5426 /++ 5427 5428 Adds all own enumerable string keyed function properties of a source object 5429 to the destination object. If object is a function, then methods are added 5430 to its prototype as well. 5431 5432 Note: Use _.runInContext to create a pristine lodash function to avoid 5433 conflicts caused by modifying the original. 5434 5435 Params: 5436 - source (Object): The object of functions to add. 5437 - [options={}] (Object): The options object. 5438 - [options.chain=true] (boolean): Specify whether mixins are chainable. 5439 5440 Returns: 5441 - Lodash chained on (*): object. 5442 5443 +/ 5444 auto ref mixin_(T, U = Any)(auto ref T source, auto ref U options = U.init) { 5445 setupMemory(); 5446 Command c = Command("mixin"); 5447 c.setHandleOrEval(source); 5448 if (options) c.setHandleOrEval(options); 5449 tryPut(c); 5450 return this; 5451 } 5452 5453 /++ 5454 5455 Binds methods of an object to the object itself, overwriting the existing method. 5456 5457 Note: This method doesn't set the "length" property of bound functions. 5458 5459 Params: 5460 - methodNames (...(string|string[])): The object method names to bind. 5461 5462 Returns: 5463 - Lodash chained on (Object): object. 5464 5465 +/ 5466 auto ref bindAll(ARGS...)(auto ref ARGS methodNames) { 5467 setupMemory(); 5468 Command c = Command("bindAll"); 5469 foreach(ref method; methodNames) c.setString(method); 5470 tryPut(c); 5471 return this; 5472 } 5473 5474 /++ 5475 5476 Checks value to determine whether a default value should be returned in its place. 5477 The defaultValue is returned if value is NaN, null, or undefined. 5478 5479 Params: 5480 - defaultValue (*): The default value. 5481 5482 Returns: 5483 - Lodash chained on (*): the resolved value. 5484 5485 +/ 5486 auto ref defaultTo(T)(auto ref T defaultValue) { 5487 setupMemory(); 5488 Command c = Command("defaultTo"); 5489 c.setAnyValue(defaultValue); 5490 tryPut(c); 5491 return this; 5492 } 5493 5494 /++ 5495 5496 Converts value to a property path array. 5497 5498 Returns: 5499 - Lodash chained on (Array): the new property path array. 5500 5501 +/ 5502 auto ref toPath()() { 5503 setupMemory(); 5504 Command c = Command("toPath"); 5505 tryPut(c); 5506 return this; 5507 } 5508 5509 /++ 5510 5511 Create a new pristine lodash function using the context object. 5512 5513 Returns: 5514 - Lodash chained on (Function): a new lodash function. 5515 5516 +/ 5517 auto ref runInContext()() { 5518 setupMemory(); 5519 Command c = Command("runInContext"); 5520 tryPut(c); 5521 return this; 5522 } 5523 5524 /++ 5525 Executes the compute commands accumulated so far 5526 5527 Returns: 5528 A value cast to type T 5529 +/ 5530 @trusted T execute(T)() { 5531 m_ptr--; *(m_ptr++) = ']'; // replace the last comma 5532 scope(exit) { 5533 // reset 5534 m_ptr = m_commands.ptr; 5535 m_cb.any = null; 5536 m_cbType = VarType.init; 5537 m_error = null; 5538 FL_deallocate(m_commands); 5539 m_commands = null; 5540 5541 // we keep the init val? 5542 } 5543 string commands = cast(string) m_commands[0 .. m_commands.length - (m_commands.length - (m_ptr - m_commands.ptr))]; 5544 switch (m_initType) { 5545 case VarType.handle: 5546 static if (isSomeString!T) 5547 return ldexec_Handle__string(m_initVal.handle, commands, m_cb.any, m_error); 5548 else static if (isNumeric!T && !is(T == Handle) && !isFloatingPoint!T) 5549 return ldexec_Handle__long(m_initVal.handle, commands, m_cb.any, m_error); 5550 else static if (isFloatingPoint!T) 5551 return ldexec_Handle__double(m_initVal.handle, commands, m_cb.any, m_error); 5552 else 5553 return T(ldexec_Handle__Handle(m_initVal.handle, commands, m_cb.any, m_error)); 5554 5555 // fast path for D Strings operations 5556 case VarType.string_: 5557 case VarType.eval: 5558 bool is_eval_init = m_initType == VarType.eval; 5559 static if (isSomeString!T) 5560 return ldexec_string__string(m_initVal.str, commands, m_cb.any, m_error, is_eval_init); 5561 else static if (isNumeric!T && !is(T == Handle) && !isFloatingPoint!T) 5562 return ldexec_string__long(m_initVal.str, commands, m_cb.any, m_error, is_eval_init); 5563 else static if (isFloatingPoint!T) 5564 return ldexec_string__double(m_initVal.str, commands, m_cb.any, m_error, is_eval_init); 5565 else 5566 return T(ldexec_string__Handle(m_initVal.str, commands, m_cb.any, m_error, is_eval_init)); 5567 5568 // fast path for D Numeric operations 5569 case VarType.number: 5570 static if (isSomeString!T) 5571 return ldexec_long__string(m_initVal.number, commands, m_cb.any, m_error); 5572 else static if (isNumeric!T && !is(T == Handle) && !isFloatingPoint!T) 5573 return ldexec_long__long(m_initVal.number, commands, m_cb.any, m_error); 5574 else static if (isFloatingPoint!T) 5575 return ldexec_long__double(m_initVal.number, commands, m_cb.any, m_error); 5576 else 5577 return T(ldexec_long__Handle(m_initVal.number, commands, m_cb.any, m_error)); 5578 5579 default: assert(false, "Init type not implemented"); 5580 5581 } 5582 5583 } 5584 5585 5586 5587 }