-
Notifications
You must be signed in to change notification settings - Fork 53
/
countryiso.js
1477 lines (1326 loc) · 51.9 KB
/
countryiso.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var process=require("__browserify_process");var fs = require('fs')
, _ =
{ object: require('lodash.zipobject')
, map: require('lodash.map')
, invert: require('lodash.invert')
}
, f = "AFGHANISTAN;AF\nÅLAND ISLANDS;AX\nALBANIA;AL\nALGERIA;DZ\nAMERICAN SAMOA;AS\nANDORRA;AD\nANGOLA;AO\nANGUILLA;AI\nANTARCTICA;AQ\nANTIGUA AND BARBUDA;AG\nARGENTINA;AR\nARMENIA;AM\nARUBA;AW\nAUSTRALIA;AU\nAUSTRIA;AT\nAZERBAIJAN;AZ\nBAHAMAS;BS\nBAHRAIN;BH\nBANGLADESH;BD\nBARBADOS;BB\nBELARUS;BY\nBELGIUM;BE\nBELIZE;BZ\nBENIN;BJ\nBERMUDA;BM\nBHUTAN;BT\nBOLIVIA, PLURINATIONAL STATE OF;BO\nBONAIRE, SINT EUSTATIUS AND SABA;BQ\nBOSNIA AND HERZEGOVINA;BA\nBOTSWANA;BW\nBOUVET ISLAND;BV\nBRAZIL;BR\nBRITISH INDIAN OCEAN TERRITORY;IO\nBRUNEI DARUSSALAM;BN\nBULGARIA;BG\nBURKINA FASO;BF\nBURUNDI;BI\nCAMBODIA;KH\nCAMEROON;CM\nCANADA;CA\nCAPE VERDE;CV\nCAYMAN ISLANDS;KY\nCENTRAL AFRICAN REPUBLIC;CF\nCHAD;TD\nCHILE;CL\nCHINA;CN\nCHRISTMAS ISLAND;CX\nCOCOS (KEELING) ISLANDS;CC\nCOLOMBIA;CO\nCOMOROS;KM\nCONGO;CG\nCONGO, THE DEMOCRATIC REPUBLIC OF THE;CD\nCOOK ISLANDS;CK\nCOSTA RICA;CR\nCÔTE D'IVOIRE;CI\nCROATIA;HR\nCUBA;CU\nCURAÇAO;CW\nCYPRUS;CY\nCZECH REPUBLIC;CZ\nDENMARK;DK\nDJIBOUTI;DJ\nDOMINICA;DM\nDOMINICAN REPUBLIC;DO\nECUADOR;EC\nEGYPT;EG\nEL SALVADOR;SV\nEQUATORIAL GUINEA;GQ\nERITREA;ER\nESTONIA;EE\nETHIOPIA;ET\nFALKLAND ISLANDS (MALVINAS);FK\nFAROE ISLANDS;FO\nFIJI;FJ\nFINLAND;FI\nFRANCE;FR\nFRENCH GUIANA;GF\nFRENCH POLYNESIA;PF\nFRENCH SOUTHERN TERRITORIES;TF\nGABON;GA\nGAMBIA;GM\nGEORGIA;GE\nGERMANY;DE\nGHANA;GH\nGIBRALTAR;GI\nGREECE;GR\nGREENLAND;GL\nGRENADA;GD\nGUADELOUPE;GP\nGUAM;GU\nGUATEMALA;GT\nGUERNSEY;GG\nGUINEA;GN\nGUINEA-BISSAU;GW\nGUYANA;GY\nHAITI;HT\nHEARD ISLAND AND MCDONALD ISLANDS;HM\nHOLY SEE (VATICAN CITY STATE);VA\nHONDURAS;HN\nHONG KONG;HK\nHUNGARY;HU\nICELAND;IS\nINDIA;IN\nINDONESIA;ID\nIRAN, ISLAMIC REPUBLIC OF;IR\nIRAQ;IQ\nIRELAND;IE\nISLE OF MAN;IM\nISRAEL;IL\nITALY;IT\nJAMAICA;JM\nJAPAN;JP\nJERSEY;JE\nJORDAN;JO\nKAZAKHSTAN;KZ\nKENYA;KE\nKIRIBATI;KI\nKOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF;KP\nKOREA, REPUBLIC OF;KR\nKUWAIT;KW\nKYRGYZSTAN;KG\nLAO PEOPLE'S DEMOCRATIC REPUBLIC;LA\nLATVIA;LV\nLEBANON;LB\nLESOTHO;LS\nLIBERIA;LR\nLIBYA;LY\nLIECHTENSTEIN;LI\nLITHUANIA;LT\nLUXEMBOURG;LU\nMACAO;MO\nMACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF;MK\nMADAGASCAR;MG\nMALAWI;MW\nMALAYSIA;MY\nMALDIVES;MV\nMALI;ML\nMALTA;MT\nMARSHALL ISLANDS;MH\nMARTINIQUE;MQ\nMAURITANIA;MR\nMAURITIUS;MU\nMAYOTTE;YT\nMEXICO;MX\nMICRONESIA, FEDERATED STATES OF;FM\nMOLDOVA, REPUBLIC OF;MD\nMONACO;MC\nMONGOLIA;MN\nMONTENEGRO;ME\nMONTSERRAT;MS\nMOROCCO;MA\nMOZAMBIQUE;MZ\nMYANMAR;MM\nNAMIBIA;NA\nNAURU;NR\nNEPAL;NP\nNETHERLANDS;NL\nNEW CALEDONIA;NC\nNEW ZEALAND;NZ\nNICARAGUA;NI\nNIGER;NE\nNIGERIA;NG\nNIUE;NU\nNORFOLK ISLAND;NF\nNORTHERN MARIANA ISLANDS;MP\nNORWAY;NO\nOMAN;OM\nPAKISTAN;PK\nPALAU;PW\nPALESTINE, STATE OF;PS\nPANAMA;PA\nPAPUA NEW GUINEA;PG\nPARAGUAY;PY\nPERU;PE\nPHILIPPINES;PH\nPITCAIRN;PN\nPOLAND;PL\nPORTUGAL;PT\nPUERTO RICO;PR\nQATAR;QA\nRÉUNION;RE\nROMANIA;RO\nRUSSIAN FEDERATION;RU\nRWANDA;RW\nSAINT BARTHÉLEMY;BL\nSAINT HELENA, ASCENSION AND TRISTAN DA CUNHA;SH\nSAINT KITTS AND NEVIS;KN\nSAINT LUCIA;LC\nSAINT MARTIN (FRENCH PART);MF\nSAINT PIERRE AND MIQUELON;PM\nSAINT VINCENT AND THE GRENADINES;VC\nSAMOA;WS\nSAN MARINO;SM\nSAO TOME AND PRINCIPE;ST\nSAUDI ARABIA;SA\nSENEGAL;SN\nSERBIA;RS\nSEYCHELLES;SC\nSIERRA LEONE;SL\nSINGAPORE;SG\nSINT MAARTEN (DUTCH PART);SX\nSLOVAKIA;SK\nSLOVENIA;SI\nSOLOMON ISLANDS;SB\nSOMALIA;SO\nSOUTH AFRICA;ZA\nSOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS;GS\nSOUTH SUDAN;SS\nSPAIN;ES\nSRI LANKA;LK\nSUDAN;SD\nSURINAME;SR\nSVALBARD AND JAN MAYEN;SJ\nSWAZILAND;SZ\nSWEDEN;SE\nSWITZERLAND;CH\nSYRIAN ARAB REPUBLIC;SY\nTAIWAN, PROVINCE OF CHINA;TW\nTAJIKISTAN;TJ\nTANZANIA, UNITED REPUBLIC OF;TZ\nTHAILAND;TH\nTIMOR-LESTE;TL\nTOGO;TG\nTOKELAU;TK\nTONGA;TO\nTRINIDAD AND TOBAGO;TT\nTUNISIA;TN\nTURKEY;TR\nTURKMENISTAN;TM\nTURKS AND CAICOS ISLANDS;TC\nTUVALU;TV\nUGANDA;UG\nUKRAINE;UA\nUNITED ARAB EMIRATES;AE\nUNITED KINGDOM;GB\nUNITED STATES;US\nUNITED STATES MINOR OUTLYING ISLANDS;UM\nURUGUAY;UY\nUZBEKISTAN;UZ\nVANUATU;VU\nVENEZUELA, BOLIVARIAN REPUBLIC OF;VE\nVIET NAM;VN\nVIRGIN ISLANDS, BRITISH;VG\nVIRGIN ISLANDS, U.S.;VI\nWALLIS AND FUTUNA;WF\nWESTERN SAHARA;EH\nYEMEN;YE\nZAMBIA;ZM\nZIMBABWE;ZW".toString()
;
var iso = _.object(_.map(f.split('\n'), function (line) { return line.split(';') }))
// Additions
iso['USA'] = 'us'
iso['UK'] = 'gb'
var riso = _.invert(iso)
;
function country (str, url) {
if (!url) url = 'https://raw.github.com/mikeal/countryico/master/images/'
if (url[url.length -1] !== '/') url += '/'
if (str.indexOf(',')) str = str.slice(str.lastIndexOf(',')+1)
if (str[0] === ' ') str = str.slice(1)
str = str.toUpperCase()
if (iso[str]) return url + iso[str].toLowerCase() + '.png'
if (riso[str]) return url + str.toLowerCase() + '.png'
return false
}
module.exports = country
if (process.browser) window.countryiso = country
},{"__browserify_process":3,"fs":2,"lodash.invert":6,"lodash.map":10,"lodash.zipobject":31}],2:[function(require,module,exports){
// not implemented
// The reason for having an empty file and not throwing is to allow
// untraditional implementation of this module.
},{}],3:[function(require,module,exports){
// shim for using process in browser
var process = module.exports = {};
process.nextTick = (function () {
var canSetImmediate = typeof window !== 'undefined'
&& window.setImmediate;
var canPost = typeof window !== 'undefined'
&& window.postMessage && window.addEventListener
;
if (canSetImmediate) {
return function (f) { return window.setImmediate(f) };
}
if (canPost) {
var queue = [];
window.addEventListener('message', function (ev) {
if (ev.source === window && ev.data === 'process-tick') {
ev.stopPropagation();
if (queue.length > 0) {
var fn = queue.shift();
fn();
}
}
}, true);
return function nextTick(fn) {
queue.push(fn);
window.postMessage('process-tick', '*');
};
}
return function nextTick(fn) {
setTimeout(fn, 0);
};
})();
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.binding = function (name) {
throw new Error('process.binding is not supported');
}
// TODO(shtylman)
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
},{}],4:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
/** Used to determine if values are of the language type Object */
var objectTypes = {
'boolean': false,
'function': true,
'object': true,
'number': false,
'string': false,
'undefined': false
};
module.exports = objectTypes;
},{}],5:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
/** Used for native method references */
var objectProto = Object.prototype;
/** Used to detect if a method is native */
var reNative = RegExp('^' +
String(objectProto.valueOf)
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
.replace(/valueOf|for [^\]]+/g, '.+?') + '$'
);
module.exports = reNative;
},{}],6:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var keys = require('lodash.keys');
/**
* Creates an object composed of the inverted keys and values of the given object.
*
* @static
* @memberOf _
* @category Objects
* @param {Object} object The object to invert.
* @returns {Object} Returns the created inverted object.
* @example
*
* _.invert({ 'first': 'moe', 'second': 'larry' });
* // => { 'moe': 'first', 'larry': 'second' }
*/
function invert(object) {
var index = -1,
props = keys(object),
length = props.length,
result = {};
while (++index < length) {
var key = props[index];
result[object[key]] = key;
}
return result;
}
module.exports = invert;
},{"lodash.keys":8}],7:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var objectTypes = require('lodash._objecttypes');
/**
* Checks if `value` is the language type of Object.
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @category Objects
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if the `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(1);
* // => false
*/
function isObject(value) {
// check if the value is the ECMAScript language type of Object
// http://es5.github.io/#x8
// and avoid a V8 bug
// http://code.google.com/p/v8/issues/detail?id=2291
return !!(value && objectTypes[typeof value]);
}
module.exports = isObject;
},{"lodash._objecttypes":4}],8:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var isObject = require('lodash.isobject'),
reNative = require('lodash._renative'),
shimKeys = require('lodash._shimkeys');
/** Used for native method references */
var objectProto = Object.prototype;
/* Native method shortcuts for methods with the same name as other `lodash` methods */
var nativeKeys = reNative.test(nativeKeys = Object.keys) && nativeKeys;
/**
* Creates an array composed of the own enumerable property names of an object.
*
* @static
* @memberOf _
* @category Objects
* @param {Object} object The object to inspect.
* @returns {Array} Returns an array of property names.
* @example
*
* _.keys({ 'one': 1, 'two': 2, 'three': 3 });
* // => ['one', 'two', 'three'] (property order is not guaranteed across environments)
*/
var keys = !nativeKeys ? shimKeys : function(object) {
if (!isObject(object)) {
return [];
}
return nativeKeys(object);
};
module.exports = keys;
},{"lodash._renative":5,"lodash._shimkeys":9,"lodash.isobject":7}],9:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var objectTypes = require('lodash._objecttypes');
/** Used for native method references */
var objectProto = Object.prototype;
/** Native method shortcuts */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* A fallback implementation of `Object.keys` which produces an array of the
* given object's own enumerable property names.
*
* @private
* @type Function
* @param {Object} object The object to inspect.
* @returns {Array} Returns an array of property names.
*/
var shimKeys = function(object) {
var index, iterable = object, result = [];
if (!iterable) return result;
if (!(objectTypes[typeof object])) return result;
for (index in iterable) {
if (hasOwnProperty.call(iterable, index)) {
result.push(index);
}
}
return result
};
module.exports = shimKeys;
},{"lodash._objecttypes":4}],10:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var createCallback = require('lodash.createcallback'),
forOwn = require('lodash.forown');
/**
* Creates an array of values by running each element in the collection
* through the callback. The callback is bound to `thisArg` and invoked with
* three arguments; (value, index|key, collection).
*
* If a property name is provided for `callback` the created "_.pluck" style
* callback will return the property value of the given element.
*
* If an object is provided for `callback` the created "_.where" style callback
* will return `true` for elements that have the properties of the given object,
* else `false`.
*
* @static
* @memberOf _
* @alias collect
* @category Collections
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [callback=identity] The function called
* per iteration. If a property name or object is provided it will be used
* to create a "_.pluck" or "_.where" style callback, respectively.
* @param {*} [thisArg] The `this` binding of `callback`.
* @returns {Array} Returns a new array of the results of each `callback` execution.
* @example
*
* _.map([1, 2, 3], function(num) { return num * 3; });
* // => [3, 6, 9]
*
* _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
* // => [3, 6, 9] (property order is not guaranteed across environments)
*
* var stooges = [
* { 'name': 'moe', 'age': 40 },
* { 'name': 'larry', 'age': 50 }
* ];
*
* // using "_.pluck" callback shorthand
* _.map(stooges, 'name');
* // => ['moe', 'larry']
*/
function map(collection, callback, thisArg) {
var index = -1,
length = collection ? collection.length : 0;
callback = createCallback(callback, thisArg, 3);
if (typeof length == 'number') {
var result = Array(length);
while (++index < length) {
result[index] = callback(collection[index], index, collection);
}
} else {
result = [];
forOwn(collection, function(value, key, collection) {
result[++index] = callback(value, key, collection);
});
}
return result;
}
module.exports = map;
},{"lodash.createcallback":23,"lodash.forown":29}],11:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var bind = require('lodash.bind'),
identity = require('lodash.identity'),
setBindData = require('lodash._setbinddata'),
support = require('lodash.support');
/** Used to detected named functions */
var reFuncName = /^function[ \n\r\t]+\w/;
/** Used to detect functions containing a `this` reference */
var reThis = /\bthis\b/;
/** Native method shortcuts */
var fnToString = Function.prototype.toString;
/**
* The base implementation of `_.createCallback` without support for creating
* "_.pluck" or "_.where" style callbacks.
*
* @private
* @param {*} [func=identity] The value to convert to a callback.
* @param {*} [thisArg] The `this` binding of the created callback.
* @param {number} [argCount] The number of arguments the callback accepts.
* @returns {Function} Returns a callback function.
*/
function baseCreateCallback(func, thisArg, argCount) {
if (typeof func != 'function') {
return identity;
}
// exit early if there is no `thisArg`
if (typeof thisArg == 'undefined') {
return func;
}
var bindData = func.__bindData__ || (support.funcNames && !func.name);
if (typeof bindData == 'undefined') {
var source = reThis && fnToString.call(func);
if (!support.funcNames && source && !reFuncName.test(source)) {
bindData = true;
}
if (support.funcNames || !bindData) {
// checks if `func` references the `this` keyword and stores the result
bindData = !support.funcDecomp || reThis.test(source);
setBindData(func, bindData);
}
}
// exit early if there are no `this` references or `func` is bound
if (bindData !== true && (bindData && bindData[1] & 1)) {
return func;
}
switch (argCount) {
case 1: return function(value) {
return func.call(thisArg, value);
};
case 2: return function(a, b) {
return func.call(thisArg, a, b);
};
case 3: return function(value, index, collection) {
return func.call(thisArg, value, index, collection);
};
case 4: return function(accumulator, value, index, collection) {
return func.call(thisArg, accumulator, value, index, collection);
};
}
return bind(func, thisArg);
}
module.exports = baseCreateCallback;
},{"lodash._setbinddata":13,"lodash.bind":17,"lodash.identity":20,"lodash.support":21}],12:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
/**
* A no-operation function.
*
* @private
*/
function noop() {
// no operation performed
}
module.exports = noop;
},{}],13:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var getObject = require('lodash._getobject'),
noop = require('lodash._noop'),
reNative = require('lodash._renative'),
releaseObject = require('lodash._releaseobject');
/** Used for native method references */
var objectProto = Object.prototype;
var defineProperty = (function() {
try {
var o = {},
func = reNative.test(func = Object.defineProperty) && func,
result = func(o, o, o) && func;
} catch(e) { }
return result;
}());
/**
* Sets `this` binding data on a given function.
*
* @private
* @param {Function} func The function to set data on.
* @param {*} value The value to set.
*/
var setBindData = !defineProperty ? noop : function(func, value) {
var descriptor = getObject();
descriptor.value = value;
defineProperty(func, '__bindData__', descriptor);
releaseObject(descriptor);
};
module.exports = setBindData;
},{"lodash._getobject":14,"lodash._noop":12,"lodash._releaseobject":16,"lodash._renative":5}],14:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var objectPool = require('lodash._objectpool');
/**
* Gets an object from the object pool or creates a new one if the pool is empty.
*
* @private
* @returns {Object} The object from the pool.
*/
function getObject() {
return objectPool.pop() || {
'array': null,
'cache': null,
'configurable': false,
'criteria': null,
'enumerable': false,
'false': false,
'index': 0,
'leading': false,
'maxWait': 0,
'null': false,
'number': null,
'object': null,
'push': null,
'string': null,
'trailing': false,
'true': false,
'undefined': false,
'value': null,
'writable': false
};
}
module.exports = getObject;
},{"lodash._objectpool":15}],15:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
/** Used to pool arrays and objects used internally */
var objectPool = [];
module.exports = objectPool;
},{}],16:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var maxPoolSize = require('lodash._maxpoolsize'),
objectPool = require('lodash._objectpool');
/**
* Releases the given object back to the object pool.
*
* @private
* @param {Object} [object] The object to release.
*/
function releaseObject(object) {
var cache = object.cache;
if (cache) {
releaseObject(cache);
}
object.array = object.cache = object.criteria = object.object = object.number = object.string = object.value = null;
if (objectPool.length < maxPoolSize) {
objectPool.push(object);
}
}
module.exports = releaseObject;
},{"lodash._maxpoolsize":22,"lodash._objectpool":15}],17:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var createBound = require('lodash._createbound'),
reNative = require('lodash._renative');
/**
* Used for `Array` method references.
*
* Normally `Array.prototype` would suffice, however, using an array literal
* avoids issues in Narwhal.
*/
var arrayRef = [];
/* Native method shortcuts for methods with the same name as other `lodash` methods */
var nativeSlice = arrayRef.slice;
/**
* Creates a function that, when called, invokes `func` with the `this`
* binding of `thisArg` and prepends any additional `bind` arguments to those
* provided to the bound function.
*
* @static
* @memberOf _
* @category Functions
* @param {Function} func The function to bind.
* @param {*} [thisArg] The `this` binding of `func`.
* @param {...*} [arg] Arguments to be partially applied.
* @returns {Function} Returns the new bound function.
* @example
*
* var func = function(greeting) {
* return greeting + ' ' + this.name;
* };
*
* func = _.bind(func, { 'name': 'moe' }, 'hi');
* func();
* // => 'hi moe'
*/
function bind(func, thisArg) {
return arguments.length > 2
? createBound(func, 17, nativeSlice.call(arguments, 2), null, thisArg)
: createBound(func, 1, null, null, thisArg);
}
module.exports = bind;
},{"lodash._createbound":18,"lodash._renative":5}],18:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var createObject = require('lodash._createobject'),
isFunction = require('lodash.isfunction'),
isObject = require('lodash.isobject'),
reNative = require('lodash._renative'),
setBindData = require('lodash._setbinddata'),
support = require('lodash.support');
/**
* Used for `Array` method references.
*
* Normally `Array.prototype` would suffice, however, using an array literal
* avoids issues in Narwhal.
*/
var arrayRef = [];
/** Used for native method references */
var objectProto = Object.prototype;
/** Native method shortcuts */
var push = arrayRef.push,
toString = objectProto.toString,
unshift = arrayRef.unshift;
/* Native method shortcuts for methods with the same name as other `lodash` methods */
var nativeBind = reNative.test(nativeBind = toString.bind) && nativeBind,
nativeSlice = arrayRef.slice;
/**
* Creates a function that, when called, either curries or invokes `func`
* with an optional `this` binding and partially applied arguments.
*
* @private
* @param {Function|string} func The function or method name to reference.
* @param {number} bitmask The bitmask of method flags to compose.
* The bitmask may be composed of the following flags:
* 1 - `_.bind`
* 2 - `_.bindKey`
* 4 - `_.curry`
* 8 - `_.curry` (bound)
* 16 - `_.partial`
* 32 - `_.partialRight`
* @param {Array} [partialArgs] An array of arguments to prepend to those
* provided to the new function.
* @param {Array} [partialRightArgs] An array of arguments to append to those
* provided to the new function.
* @param {*} [thisArg] The `this` binding of `func`.
* @param {number} [arity] The arity of `func`.
* @returns {Function} Returns the new bound function.
*/
function createBound(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) {
var isBind = bitmask & 1,
isBindKey = bitmask & 2,
isCurry = bitmask & 4,
isCurryBound = bitmask & 8,
isPartial = bitmask & 16,
isPartialRight = bitmask & 32,
key = func;
if (!isBindKey && !isFunction(func)) {
throw new TypeError;
}
if (isPartial && !partialArgs.length) {
bitmask &= ~16;
isPartial = partialArgs = false;
}
if (isPartialRight && !partialRightArgs.length) {
bitmask &= ~32;
isPartialRight = partialRightArgs = false;
}
var bindData = func && func.__bindData__;
if (bindData) {
if (isBind && !(bindData[1] & 1)) {
bindData[4] = thisArg;
}
if (!isBind && bindData[1] & 1) {
bitmask |= 8;
}
if (isCurry && !(bindData[1] & 4)) {
bindData[5] = arity;
}
if (isPartial) {
push.apply(bindData[2] || (bindData[2] = []), partialArgs);
}
if (isPartialRight) {
push.apply(bindData[3] || (bindData[3] = []), partialRightArgs);
}
bindData[1] |= bitmask;
return createBound.apply(null, bindData);
}
// use `Function#bind` if it exists and is fast
// (in V8 `Function#bind` is slower except when partially applied)
if (isBind && !(isBindKey || isCurry || isPartialRight) &&
(support.fastBind || (nativeBind && isPartial))) {
if (isPartial) {
var args = [thisArg];
push.apply(args, partialArgs);
}
var bound = isPartial
? nativeBind.apply(func, args)
: nativeBind.call(func, thisArg);
}
else {
bound = function() {
// `Function#bind` spec
// http://es5.github.io/#x15.3.4.5
var args = arguments,
thisBinding = isBind ? thisArg : this;
if (isCurry || isPartial || isPartialRight) {
args = nativeSlice.call(args);
if (isPartial) {
unshift.apply(args, partialArgs);
}
if (isPartialRight) {
push.apply(args, partialRightArgs);
}
if (isCurry && args.length < arity) {
bitmask |= 16 & ~32;
return createBound(func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity);
}
}
if (isBindKey) {
func = thisBinding[key];
}
if (this instanceof bound) {
// ensure `new bound` is an instance of `func`
thisBinding = createObject(func.prototype);
// mimic the constructor's `return` behavior
// http://es5.github.io/#x13.2.2
var result = func.apply(thisBinding, args);
return isObject(result) ? result : thisBinding;
}
return func.apply(thisBinding, args);
};
}
setBindData(bound, nativeSlice.call(arguments));
return bound;
}
module.exports = createBound;
},{"lodash._createobject":19,"lodash._renative":5,"lodash._setbinddata":13,"lodash.isfunction":30,"lodash.isobject":7,"lodash.support":21}],19:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var isObject = require('lodash.isobject'),
noop = require('lodash._noop'),
reNative = require('lodash._renative');
/** Used for native method references */
var objectProto = Object.prototype;
/* Native method shortcuts for methods with the same name as other `lodash` methods */
var nativeCreate = reNative.test(nativeCreate = Object.create) && nativeCreate;
/**
* Creates a new object with the specified `prototype`.
*
* @private
* @param {Object} prototype The prototype object.
* @returns {Object} Returns the new object.
*/
function createObject(prototype) {
return isObject(prototype) ? nativeCreate(prototype) : {};
}
module.exports = createObject;
},{"lodash._noop":12,"lodash._renative":5,"lodash.isobject":7}],20:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
/**
* This method returns the first argument provided to it.
*
* @static
* @memberOf _
* @category Utilities
* @param {*} value Any value.
* @returns {*} Returns `value`.
* @example
*
* var moe = { 'name': 'moe' };
* moe === _.identity(moe);
* // => true
*/
function identity(value) {
return value;
}
module.exports = identity;
},{}],21:[function(require,module,exports){
var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var reNative = require('lodash._renative');
/** Used to detect functions containing a `this` reference */
var reThis = /\bthis\b/;
/** Used for native method references */
var objectProto = Object.prototype;
/** Native method shortcuts */
var toString = objectProto.toString;
/* Native method shortcuts for methods with the same name as other `lodash` methods */
var nativeBind = reNative.test(nativeBind = toString.bind) && nativeBind;
/** Detect various environments */
var isIeOpera = reNative.test(global.attachEvent),
isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera);
/**
* An object used to flag environments features.
*
* @static
* @memberOf _
* @type Object
*/
var support = {};
/**
* Detect if `Function#bind` exists and is inferred to be fast (all but V8).
*
* @memberOf _.support
* @type boolean
*/
support.fastBind = nativeBind && !isV8;
/**
* Detect if functions can be decompiled by `Function#toString`
* (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps).
*
* @memberOf _.support
* @type boolean
*/
support.funcDecomp = !reNative.test(global.WinRTError) && reThis.test(function() { return this; });
/**
* Detect if `Function#name` is supported (all but IE).
*
* @memberOf _.support
* @type boolean
*/
support.funcNames = typeof Function.name == 'string';
module.exports = support;
},{"lodash._renative":5}],22:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
/** Used as the max size of the `arrayPool` and `objectPool` */
var maxPoolSize = 40;
module.exports = maxPoolSize;
},{}],23:[function(require,module,exports){
/**
* Lo-Dash 2.1.0 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var baseCreateCallback = require('lodash._basecreatecallback'),
baseIsEqual = require('lodash._baseisequal'),
isObject = require('lodash.isobject'),
keys = require('lodash.keys');
/**
* Produces a callback bound to an optional `thisArg`. If `func` is a property
* name the created callback will return the property value for a given element.
* If `func` is an object the created callback will return `true` for elements
* that contain the equivalent object properties, otherwise it will return `false`.
*
* @static
* @memberOf _
* @category Functions
* @param {*} [func=identity] The value to convert to a callback.
* @param {*} [thisArg] The `this` binding of the created callback.
* @param {number} [argCount] The number of arguments the callback accepts.
* @returns {Function} Returns a callback function.
* @example
*
* var stooges = [
* { 'name': 'moe', 'age': 40 },
* { 'name': 'larry', 'age': 50 }
* ];
*
* // wrap to create custom callback shorthands
* _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
* var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
* return !match ? func(callback, thisArg) : function(object) {
* return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
* };
* });
*
* _.filter(stooges, 'age__gt45');
* // => [{ 'name': 'larry', 'age': 50 }]
*/
function createCallback(func, thisArg, argCount) {
var type = typeof func;
if (func == null || type == 'function') {
return baseCreateCallback(func, thisArg, argCount);
}
// handle "_.pluck" style callback shorthands
if (type != 'object') {
return function(object) {
return object[func];
};
}
var props = keys(func),
key = props[0],