├── .gitignore
├── .idea
├── misc.xml
├── modules.xml
└── vcs.xml
├── 01-Inquirerjs
├── .gitignore
├── README.md
├── examples
│ ├── 01_input.js
│ ├── 02_confirm.js
│ ├── 03_list.js
│ ├── 04_rawlist.js
│ ├── 05_expand.js
│ ├── 06_long-list.js
│ ├── 07_checkbox.js
│ ├── 08_password.js
│ ├── 09_editor.js
│ ├── 10_bottom-bar.js
│ ├── 11_hierarchical.js
│ ├── 12_nested-call.js
│ ├── 13_recursive.js
│ ├── 14_spawn.js
│ ├── 15_when.js
│ ├── 16_rx-observable-array.js
│ └── 17_rx-observable-create.js
├── images
│ ├── bottom-bar.png
│ ├── checkbox.png
│ ├── confirm.png
│ ├── editor.png
│ ├── expand.png
│ ├── input.png
│ ├── list.png
│ ├── password.png
│ └── rawlist.png
└── package.json
├── 02-Lodash
├── .gitignore
├── README.md
├── examples
│ ├── array
│ │ ├── 01_chunk.js
│ │ ├── 02_compact.js
│ │ ├── 03_concat.js
│ │ ├── 04_difference.js
│ │ ├── 05_differenceby.js
│ │ ├── 06_differencewith.js
│ │ ├── 07_drop.js
│ │ ├── 08_dropright.js
│ │ ├── 09_droprightwhile.js
│ │ ├── 10_dropwhile.js
│ │ ├── 11_fill.js
│ │ ├── 12_findindex.js
│ │ ├── 13_findlastindex.js
│ │ ├── 14_first.js
│ │ ├── 15_flatten.js
│ │ ├── 16_flattendeep.js
│ │ ├── 17_flattendepth.js
│ │ ├── 18_fromparis.js
│ │ ├── 19_head.js
│ │ ├── 20_indexof.js
│ │ ├── 21_initial.js
│ │ ├── 22_intersection.js
│ │ ├── 23_intersectionby.js
│ │ ├── 24_intersectionwith.js
│ │ ├── 25_join.js
│ │ ├── 26_last.js
│ │ ├── 27_lastindexof.js
│ │ ├── 28_nth.js
│ │ ├── 29_pull.js
│ │ ├── 30_pullall.js
│ │ ├── 31_pullallby.js
│ │ ├── 32_pullallwith.js
│ │ ├── 33_pullat.js
│ │ ├── 34_remove.js
│ │ ├── 35_reverse.js
│ │ ├── 36_slice.js
│ │ ├── 37_sortedindex.js
│ │ ├── 38_sortedindexby.js
│ │ ├── 39_sortedindexof.js
│ │ ├── 40_sortedlastindex.js
│ │ ├── 41_sortedlastindexby.js
│ │ ├── 42_sortedlastindexof.js
│ │ ├── 43_sorteduniq.js
│ │ ├── 44_sorteduniqby.js
│ │ ├── 45_tail.js
│ │ ├── 46_take.js
│ │ ├── 47_takeright.js
│ │ ├── 48_takerightwhile.js
│ │ ├── 49_takewhile.js
│ │ ├── 50_union.js
│ │ ├── 51_unionby.js
│ │ ├── 52_unionwith.js
│ │ ├── 53_uniq.js
│ │ ├── 54_uniqby.js
│ │ ├── 55_uniqwith.js
│ │ ├── 56_unzip.js
│ │ ├── 57_unzipwith.js
│ │ ├── 58_without.js
│ │ ├── 59_xor.js
│ │ ├── 60_xorby.js
│ │ ├── 61_xorwith.js
│ │ ├── 62_zip.js
│ │ ├── 63_zipobject.js
│ │ ├── 64_zipobjectdeep.js
│ │ └── 65_zipwith.js
│ ├── collection
│ │ ├── 01_countby.js
│ │ ├── 02_each.js
│ │ ├── 03_eachright.js
│ │ ├── 04_every.js
│ │ ├── 05_filter.js
│ │ ├── 06_find.js
│ │ ├── 07_findlast.js
│ │ ├── 08_flatmap.js
│ │ ├── 09_flatmapdeep.js
│ │ ├── 10_flatmapdepth.js
│ │ ├── 11_foreach.js
│ │ ├── 12_foreachright.js
│ │ ├── 13_groupby.js
│ │ ├── 14_includes.js
│ │ ├── 15_invokemap.js
│ │ ├── 16_keyby.js
│ │ ├── 17_map.js
│ │ ├── 18_orderby.js
│ │ ├── 19_partition.js
│ │ ├── 20_reduce.js
│ │ ├── 21_reduceright.js
│ │ ├── 22_reject.js
│ │ ├── 23_sample.js
│ │ ├── 24_samplesize.js
│ │ ├── 25_shuffle.js
│ │ ├── 26_size.js
│ │ ├── 27_some.js
│ │ └── 28_sortby.js
│ ├── date
│ │ └── 01_now.js
│ ├── function
│ │ ├── 01_after.js
│ │ ├── 02_ary.js
│ │ ├── 03_before.js
│ │ ├── 04_bind.js
│ │ ├── 05_bindkey.js
│ │ ├── 06_curry.js
│ │ ├── 07_curryright.js
│ │ ├── 08_debounce.js
│ │ ├── 09_defer.js
│ │ ├── 10_delay.js
│ │ ├── 11_flip.js
│ │ ├── 12_memoize.js
│ │ ├── 13_negate.js
│ │ ├── 14_once.js
│ │ ├── 15_overargs.js
│ │ ├── 16_partial.js
│ │ ├── 17_partialright.js
│ │ ├── 18_rearg.js
│ │ ├── 19_rest.js
│ │ ├── 20_spread.js
│ │ ├── 21_throttle.js
│ │ ├── 22_unary.js
│ │ └── 23_wrap.js
│ ├── lang
│ │ ├── 01_castarray.js
│ │ ├── 02_clone.js
│ │ ├── 03_clonedeep.js
│ │ ├── 04_clonedeepwith.js
│ │ ├── 05_clonewith.js
│ │ ├── 06_confirmsto.js
│ │ ├── 07_eq.js
│ │ ├── 08_gt.js
│ │ ├── 09_gte.js
│ │ ├── 10_isarguments.js
│ │ ├── 11_isarray.js
│ │ ├── 12_isarraybuffer.js
│ │ ├── 13_isarraylike.js
│ │ ├── 14_isarraylikeobject.js
│ │ ├── 15_isboolean.js
│ │ ├── 16_isbuffer.js
│ │ ├── 17_isdate.js
│ │ ├── 18_iselement.js
│ │ ├── 19_isempty.js
│ │ ├── 20_isequal.js
│ │ ├── 21_isequalwith.js
│ │ ├── 22_iserror.js
│ │ ├── 23_isfinite.js
│ │ ├── 24_isfunction.js
│ │ ├── 25_islength.js
│ │ ├── 26_isinteger.js
│ │ ├── 27_ismap.js
│ │ ├── 28_ismatch.js
│ │ ├── 29_ismatchwith.js
│ │ ├── 30_isnan.js
│ │ ├── 31_isnative.js
│ │ ├── 32_isnil.js
│ │ ├── 33_isnull.js
│ │ ├── 34_isnumber.js
│ │ ├── 35_isobject.js
│ │ ├── 36_isobjectlike.js
│ │ ├── 37_isplainobject.js
│ │ ├── 38_isregexp.js
│ │ ├── 39_issafeinteger.js
│ │ ├── 40_isset.js
│ │ ├── 41_isstring.js
│ │ ├── 42_issymbol.js
│ │ ├── 43_istypedarray.js
│ │ ├── 44_isundefined.js
│ │ ├── 45_isweakmap.js
│ │ ├── 46_isweakset.js
│ │ ├── 47_lt.js
│ │ ├── 48_lte.js
│ │ ├── 49_toarray.js
│ │ ├── 50_tofinite.js
│ │ ├── 51_tointeger.js
│ │ ├── 52_tolength.js
│ │ ├── 53_tonumber.js
│ │ ├── 54_toplainobject.js
│ │ ├── 55_tosafeinteger.js
│ │ └── 56_tostring.js
│ ├── math
│ │ ├── 01_add.js
│ │ ├── 02_ceil.js
│ │ ├── 03_divide.js
│ │ ├── 04_floor.js
│ │ ├── 05_max.js
│ │ ├── 06_maxby.js
│ │ ├── 07_mean.js
│ │ ├── 08_meanby.js
│ │ ├── 09_min.js
│ │ ├── 10_minby.js
│ │ ├── 11_multiply.js
│ │ ├── 12_round.js
│ │ ├── 13_subtract.js
│ │ ├── 14_sum.js
│ │ └── 15_sumby.js
│ ├── methods
│ │ └── 01_ref-lodash-func.js
│ ├── number
│ │ ├── 01_clamp.js
│ │ ├── 02_inrange.js
│ │ └── 03_random.js
│ ├── object
│ │ ├── 01_assign.js
│ │ ├── 02_assignin.js
│ │ ├── 03_assigninwith.js
│ │ ├── 04_assignwith.js
│ │ ├── 05_at.js
│ │ ├── 06_create.js
│ │ ├── 07_defaults.js
│ │ ├── 08_defaultsdeep.js
│ │ ├── 09_entries.js
│ │ ├── 10_entriesin.js
│ │ ├── 11_extend.js
│ │ ├── 12_extendwith.js
│ │ ├── 13_findkey.js
│ │ ├── 14_findlastkey.js
│ │ ├── 15_forin.js
│ │ ├── 16_forinright.js
│ │ ├── 17_forown.js
│ │ ├── 18_forownright.js
│ │ ├── 19_functions.js
│ │ ├── 20_functionsin.js
│ │ ├── 21_get.js
│ │ ├── 22_has.js
│ │ ├── 23_hasin.js
│ │ ├── 24_invert.js
│ │ ├── 25_invertby.js
│ │ ├── 26_invoke.js
│ │ ├── 27_keys.js
│ │ ├── 28_keysin.js
│ │ ├── 29_mapkeys.js
│ │ ├── 30_mapvalues.js
│ │ ├── 31_merge.js
│ │ ├── 32_mergewith.js
│ │ ├── 33_omit.js
│ │ ├── 34_omitby.js
│ │ ├── 35_pick.js
│ │ ├── 36_pickby.js
│ │ ├── 37_result.js
│ │ ├── 38_set.js
│ │ ├── 39_setwith.js
│ │ ├── 40_topairs.js
│ │ ├── 41_topairsin.js
│ │ ├── 42_transform.js
│ │ ├── 43_unset.js
│ │ ├── 44_update.js
│ │ ├── 45_updatewith.js
│ │ ├── 46_values.js
│ │ └── 47_valuesin.js
│ ├── properties
│ │ ├── 01_version.js
│ │ ├── 02_templatesettings.js
│ │ ├── 03_templatesettings-escape.js
│ │ ├── 04_templatesettings-evaluate.js
│ │ ├── 05_templatesettings-imports.js
│ │ ├── 06_templatesettings-interpolate.js
│ │ └── 07_templatesettings-variable.js
│ ├── seq
│ │ ├── 01_lodash.js
│ │ ├── 02_chain.js
│ │ ├── 03_tap.js
│ │ ├── 04_thru.js
│ │ ├── 05_prototype-symbol.js
│ │ ├── 06_prototype-at.js
│ │ ├── 07_prototype-chain.js
│ │ ├── 08_prototype-commit.js
│ │ ├── 09_prototype-next.js
│ │ ├── 10_prototype-plant.js
│ │ ├── 11_prototype-reverse.js
│ │ ├── 12_prototype-json.js
│ │ ├── 13_prototype-value.js
│ │ └── 14_prototype-valueof.js
│ ├── string
│ │ ├── 01_camelcase.js
│ │ ├── 02_capitalize.js
│ │ ├── 03_deburr.js
│ │ ├── 04_endswith.js
│ │ ├── 05_escape.js
│ │ ├── 06_escaperegexp.js
│ │ ├── 07_kebabcase.js
│ │ ├── 08_lowercase.js
│ │ ├── 09_lowerfirst.js
│ │ ├── 10_pad.js
│ │ ├── 11_padend.js
│ │ ├── 12_padstart.js
│ │ ├── 13_parseint.js
│ │ ├── 14_repeat.js
│ │ ├── 15_replace.js
│ │ ├── 16_snakecase.js
│ │ ├── 17_split.js
│ │ ├── 18_startcase.js
│ │ ├── 19_startswith.js
│ │ ├── 20_template.js
│ │ ├── 21_tolower.js
│ │ ├── 22_toupper.js
│ │ ├── 23_trim.js
│ │ ├── 24_trimend.js
│ │ ├── 25_trimstart.js
│ │ ├── 26_truncate.js
│ │ ├── 27_unescape.js
│ │ ├── 28_uppercase.js
│ │ ├── 29_upperfirst.js
│ │ └── 30_words.js
│ └── util
│ │ ├── 01_attempt.js
│ │ ├── 02_bindall.js
│ │ ├── 03_cond.js
│ │ ├── 04_conforms.js
│ │ ├── 05_constant.js
│ │ ├── 06_defaultto.js
│ │ ├── 07_flow.js
│ │ ├── 08_flowright.js
│ │ ├── 09_identity.js
│ │ ├── 10_iteratee.js
│ │ ├── 11_matches.js
│ │ ├── 12_matchesproperty.js
│ │ ├── 13_method.js
│ │ ├── 14_methodof.js
│ │ ├── 15_mixin.js
│ │ ├── 16_noconflict.js
│ │ ├── 17_noop.js
│ │ ├── 18_ntharg.js
│ │ ├── 19_over.js
│ │ ├── 20_overevery.js
│ │ ├── 21_oversome.js
│ │ ├── 22_property.js
│ │ ├── 23_propertyof.js
│ │ ├── 24_range.js
│ │ ├── 25_rangeright.js
│ │ ├── 26_runincontext.js
│ │ ├── 27_stubarray.js
│ │ ├── 28_stubfalse.js
│ │ ├── 29_stubobject.js
│ │ ├── 30_stubstring.js
│ │ ├── 31_stubtrue.js
│ │ ├── 32_times.js
│ │ ├── 33_topath.js
│ │ └── 34_uniqueid.js
└── package.json
├── 03-Webpack
├── 01-basic
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ ├── one.js
│ │ └── two.js
│ └── webpack.config.js
├── 02-babel-loader
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ ├── one.js
│ │ └── two.js
│ └── webpack.config.js
├── 03-css-loader
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ ├── css
│ │ │ └── introComponent.css
│ │ ├── one.js
│ │ └── two.js
│ └── webpack.config.js
├── 04-sass-loader
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ ├── css
│ │ │ └── introComponent.scss
│ │ ├── one.js
│ │ └── two.js
│ └── webpack.config.js
├── README.md
└── images
│ ├── one.png
│ └── two.png
├── 04-RxJS
└── README.md
├── 05-TypeScript
├── 01-basicTypes
│ ├── 01_boolean.ts
│ ├── 02_number.ts
│ ├── 03_string.ts
│ ├── 04_array.ts
│ ├── 05_tuple.ts
│ ├── 06_enum.ts
│ ├── 07_any.ts
│ ├── 08_void.ts
│ ├── 09_unused.ts
│ └── 10_never.ts
├── 02-interfaces
│ ├── 01_firstinterface.ts
│ ├── 02_optionalparams.ts
│ └── 03_readonlyparams.ts
├── 03-classes
│ └── 01_inheritance.ts
├── 04-functions
│ ├── 01_functiontypes.ts
│ ├── 02_inferringtypes.ts
│ ├── 03_optionals&defaults.ts
│ └── 04_restparameters.ts
├── 05-generics
│ └── 01_basic.ts
├── 06-enums
│ └── 01_basic.ts
└── README.md
├── README.md
└── javascript-frameworks.iml
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 | .idea
4 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
' + func(text) + '
'; 10 | }); 11 | 12 | console.log(p('fred, barney, & pebbles')); 13 | // => 'fred, barney, & pebbles
' -------------------------------------------------------------------------------- /02-Lodash/examples/lang/01_castarray.js: -------------------------------------------------------------------------------- 1 | /** 2 | * castArray example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.castArray(1)); 9 | // => [1] 10 | 11 | console.log(_.castArray({ 'a': 1 })); 12 | // => [{ 'a': 1 }] 13 | 14 | console.log(_.castArray('abc')); 15 | // => ['abc'] 16 | 17 | console.log(_.castArray(null)); 18 | // => [null] 19 | 20 | console.log(_.castArray(undefined)); 21 | // => [undefined] 22 | 23 | console.log(_.castArray()); 24 | // => [] 25 | 26 | var array = [1, 2, 3]; 27 | console.log(_.castArray(array) === array); 28 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/lang/02_clone.js: -------------------------------------------------------------------------------- 1 | /** 2 | * clone example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var objects = [{ 'a': 1 }, { 'b': 2 }]; 9 | 10 | var shallow = _.clone(objects); 11 | console.log(shallow); 12 | console.log(shallow[0] === objects[0]); 13 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/lang/03_clonedeep.js: -------------------------------------------------------------------------------- 1 | /** 2 | * cloneDeep example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var objects = [{ 'a': 1 }, { 'b': 2 }]; 9 | 10 | var deep = _.cloneDeep(objects); 11 | console.log(deep); 12 | console.log(deep[0] === objects[0]); 13 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/04_clonedeepwith.js: -------------------------------------------------------------------------------- 1 | /** 2 | * cloneDeepWith example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function customizer(value) { 9 | if (_.isElement(value)) { 10 | return value.cloneNode(true); 11 | } 12 | } 13 | 14 | var el = _.cloneDeepWith(document.body, customizer); 15 | 16 | console.log(el === document.body); 17 | // => false 18 | console.log(el.nodeName); 19 | // => 'BODY' 20 | console.log(el.childNodes.length); 21 | // => 20 -------------------------------------------------------------------------------- /02-Lodash/examples/lang/05_clonewith.js: -------------------------------------------------------------------------------- 1 | /** 2 | * cloneWith example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function customizer(value) { 9 | if (_.isElement(value)) { 10 | return value.cloneNode(false); 11 | } 12 | } 13 | 14 | var el = _.cloneWith(document.body, customizer); 15 | 16 | console.log(el === document.body); 17 | // => false 18 | console.log(el.nodeName); 19 | // => 'BODY' 20 | console.log(el.childNodes.length); 21 | // => 0 22 | Try in REPL 23 | -------------------------------------------------------------------------------- /02-Lodash/examples/lang/06_confirmsto.js: -------------------------------------------------------------------------------- 1 | /** 2 | * conformsTo example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': 1, 'b': 2 }; 9 | 10 | console.log(_.conformsTo(object, { 'b': function(n) { return n > 1; } })); 11 | // => true 12 | 13 | console.log(_.conformsTo(object, { 'b': function(n) { return n > 2; } })); 14 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/07_eq.js: -------------------------------------------------------------------------------- 1 | /** 2 | * eq example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.mean([1, 3, 5, 7])); 9 | // => 4 10 | 11 | var object = { 'a': 1 }; 12 | var other = { 'a': 1 }; 13 | 14 | console.log(_.eq(object, object)); 15 | // => true 16 | 17 | console.log(_.eq(object, other)); 18 | // => false 19 | 20 | console.log(_.eq('a', 'a')); 21 | // => true 22 | 23 | console.log(_.eq('a', Object('a'))); 24 | // => false 25 | 26 | console.log(_.eq(NaN, NaN)); 27 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/lang/08_gt.js: -------------------------------------------------------------------------------- 1 | /** 2 | * gt example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.gt(3, 1)); 9 | // => true 10 | 11 | console.log(_.gt(3, 3)); 12 | // => false 13 | 14 | console.log(_.gt(1, 3)); 15 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/09_gte.js: -------------------------------------------------------------------------------- 1 | /** 2 | * gte example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.gte(3, 1)); 9 | // => true 10 | 11 | console.log(_.gte(3, 3)); 12 | // => true 13 | 14 | console.log(_.gte(1, 3)); 15 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/10_isarguments.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isArguments example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isArguments(function() { return arguments; }())); 9 | // => true 10 | 11 | console.log(_.isArguments([1, 2, 3])); 12 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/11_isarray.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isArray example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isArray([1, 2, 3])); 9 | // => true 10 | 11 | console.log(_.isArray(document.body.children)); 12 | // => false 13 | 14 | console.log(_.isArray('abc')); 15 | // => false 16 | 17 | console.log(_.isArray(_.noop)); 18 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/12_isarraybuffer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isArrayBuffer example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isArrayBuffer(new ArrayBuffer(2))); 9 | // => true 10 | 11 | console.log(_.isArrayBuffer(new Array(2))); 12 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/13_isarraylike.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isArrayLike example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | 9 | console.log(_.isArrayLike([1, 2, 3])); 10 | // => true 11 | 12 | console.log(_.isArrayLike(document.body.children)); 13 | // => true 14 | 15 | console.log(_.isArrayLike('abc')); 16 | // => true 17 | 18 | console.log(_.isArrayLike(_.noop)); 19 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/14_isarraylikeobject.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isArrayLikeObject example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isArrayLikeObject([1, 2, 3])); 9 | // => true 10 | 11 | console.log(_.isArrayLikeObject(document.body.children)); 12 | // => true 13 | 14 | console.log(_.isArrayLikeObject('abc')); 15 | // => false 16 | 17 | console.log(_.isArrayLikeObject(_.noop)); 18 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/15_isboolean.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isBoolean example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isBoolean(false)); 9 | // => true 10 | 11 | console.log(_.isBoolean(null)); 12 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/16_isbuffer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isBuffer example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isBuffer(new Buffer(2))); 9 | // => true 10 | 11 | console.log(_.isBuffer(new Uint8Array(2))); 12 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/17_isdate.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isDate example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isDate(new Date)); 9 | // => true 10 | 11 | console.log(_.isDate('Mon April 23 2012')); 12 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/18_iselement.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isElement example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isElement(document.body)); 9 | // => true 10 | 11 | console.log(_.isElement('')); 12 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/19_isempty.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isEmpty example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isEmpty(null)); 9 | // => true 10 | 11 | console.log(_.isEmpty(true)); 12 | // => true 13 | 14 | console.log(_.isEmpty(1)); 15 | // => true 16 | 17 | console.log(_.isEmpty([1, 2, 3])); 18 | // => false 19 | 20 | console.log(_.isEmpty({ 'a': 1 })); 21 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/20_isequal.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isEqual example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': 1 }; 9 | var other = { 'a': 1 }; 10 | 11 | console.log(_.isEqual(object, other)); 12 | // => true 13 | 14 | console.log(object === other); 15 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/21_isequalwith.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isEqualWith example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function isGreeting(value) { 9 | return /^h(?:i|ello)$/.test(value); 10 | } 11 | 12 | function customizer(objValue, othValue) { 13 | if (isGreeting(objValue) && isGreeting(othValue)) { 14 | return true; 15 | } 16 | } 17 | 18 | var array = ['hello', 'goodbye']; 19 | var other = ['hi', 'goodbye']; 20 | 21 | console.log(_.isEqualWith(array, other, customizer)); 22 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/lang/22_iserror.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isError example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isError(new Error)); 9 | // => true 10 | 11 | console.log(_.isError(Error)); 12 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/23_isfinite.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isFinite example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isFinite(3)); 9 | // => true 10 | 11 | console.log(_.isFinite(Number.MIN_VALUE)); 12 | // => true 13 | 14 | console.log(_.isFinite(Infinity)); 15 | // => false 16 | 17 | console.log(_.isFinite('3')); 18 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/24_isfunction.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isFunction example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isFunction(_)); 9 | // => true 10 | 11 | console.log(_.isFunction(/abc/)); 12 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/25_islength.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isLength example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isLength(3)); 9 | // => true 10 | 11 | console.log(_.isLength(Number.MIN_VALUE)); 12 | // => false 13 | 14 | console.log(_.isLength(Infinity)); 15 | // => false 16 | 17 | console.log(_.isLength('3')); 18 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/26_isinteger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isInteger example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isInteger(3)); 9 | // => true 10 | 11 | console.log(_.isInteger(Number.MIN_VALUE)); 12 | // => false 13 | 14 | console.log(_.isInteger(Infinity)); 15 | // => false 16 | 17 | console.log(_.isInteger('3')); 18 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/27_ismap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isMap example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isMap(new Map)); 9 | // => true 10 | 11 | console.log(_.isMap(new WeakMap)); 12 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/28_ismatch.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isMatch example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': 1, 'b': 2 }; 9 | 10 | console.log(_.isMatch(object, { 'b': 2 })); 11 | // => true 12 | 13 | console.log(_.isMatch(object, { 'b': 1 })); 14 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/29_ismatchwith.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isMatchWith example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function isGreeting(value) { 9 | return /^h(?:i|ello)$/.test(value); 10 | } 11 | 12 | function customizer(objValue, srcValue) { 13 | if (isGreeting(objValue) && isGreeting(srcValue)) { 14 | return true; 15 | } 16 | } 17 | 18 | var object = { 'greeting': 'hello' }; 19 | var source = { 'greeting': 'hi' }; 20 | 21 | console.log(_.isMatchWith(object, source, customizer)); 22 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/lang/30_isnan.js: -------------------------------------------------------------------------------- 1 | /** 2 | * isNaN example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.isNaN(NaN)); 9 | // => true 10 | 11 | console.log(_.isNaN(new Number(NaN))); 12 | // => true 13 | 14 | console.log(isNaN(undefined)); 15 | // => true 16 | 17 | console.log(_.isNaN(undefined)); 18 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/31_isnative.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * isNative example 4 | */ 5 | 6 | 'use strict'; 7 | var _ = require('../../node_modules/lodash'); 8 | 9 | console.log(_.isNative(Array.prototype.push)); 10 | // => true 11 | 12 | console.log(_.isNative(_)); 13 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/32_isnil.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * isNil example 4 | */ 5 | 6 | 'use strict'; 7 | var _ = require('../../node_modules/lodash'); 8 | 9 | 10 | console.log(_.isNil(null)); 11 | // => true 12 | 13 | console.log(_.isNil(void 0)); 14 | // => true 15 | 16 | console.log(_.isNil(NaN)); 17 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/33_isnull.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * isNull example 4 | */ 5 | 6 | 'use strict'; 7 | var _ = require('../../node_modules/lodash'); 8 | 9 | console.log(_.isNull(null)); 10 | // => true 11 | 12 | console.log(_.isNull(void 0)); 13 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/34_isnumber.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * isNumber example 4 | */ 5 | 6 | 'use strict'; 7 | var _ = require('../../node_modules/lodash'); 8 | 9 | console.log(_.isNumber(3)); 10 | // => true 11 | 12 | console.log(_.isNumber(Number.MIN_VALUE)); 13 | // => true 14 | 15 | console.log(_.isNumber(Infinity)); 16 | // => true 17 | 18 | console.log(_.isNumber('3')); 19 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/35_isobject.js: -------------------------------------------------------------------------------- 1 | /* isObject example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.isObject({})); 8 | // => true 9 | 10 | console.log(_.isObject([1, 2, 3])); 11 | // => true 12 | 13 | console.log(_.isObject(_.noop)); 14 | // => true 15 | 16 | console.log(_.isObject(null)); 17 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/36_isobjectlike.js: -------------------------------------------------------------------------------- 1 | /* isObjectLike example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | 8 | console.log(_.isObjectLike({})); 9 | // => true 10 | 11 | console.log(_.isObjectLike([1, 2, 3])); 12 | // => true 13 | 14 | console.log(_.isObjectLike(_.noop)); 15 | // => false 16 | 17 | console.log(_.isObjectLike(null)); 18 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/37_isplainobject.js: -------------------------------------------------------------------------------- 1 | /* isPlainObject example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | function Foo() { 8 | this.a = 1; 9 | } 10 | 11 | console.log(_.isPlainObject(new Foo)); 12 | // => false 13 | 14 | console.log(_.isPlainObject([1, 2, 3])); 15 | // => false 16 | 17 | console.log(_.isPlainObject({ 'x': 0, 'y': 0 })); 18 | // => true 19 | 20 | console.log(_.isPlainObject(Object.create(null))); 21 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/lang/38_isregexp.js: -------------------------------------------------------------------------------- 1 | /* isRegExp example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.isRegExp(/abc/)); 8 | // => true 9 | 10 | console.log(_.isRegExp('/abc/')); 11 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/39_issafeinteger.js: -------------------------------------------------------------------------------- 1 | /* isSafeInteger example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.isSafeInteger(3)); 8 | // => true 9 | 10 | console.log(_.isSafeInteger(Number.MIN_VALUE)); 11 | // => false 12 | 13 | console.log(_.isSafeInteger(Infinity)); 14 | // => false 15 | 16 | console.log(_.isSafeInteger('3')); 17 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/40_isset.js: -------------------------------------------------------------------------------- 1 | /* isSet example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.isSet(new Set)); 8 | // => true 9 | 10 | console.log(_.isSet(new WeakSet)); 11 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/41_isstring.js: -------------------------------------------------------------------------------- 1 | /* isString example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.isString('abc')); 8 | // => true 9 | 10 | console.log(_.isString(1)); 11 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/42_issymbol.js: -------------------------------------------------------------------------------- 1 | /* isSymbol example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.isSymbol(Symbol.iterator)); 8 | // => true 9 | 10 | console.log(_.isSymbol('abc')); 11 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/43_istypedarray.js: -------------------------------------------------------------------------------- 1 | /* isTypedArray example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.isTypedArray(new Uint8Array)); 8 | // => true 9 | 10 | console.log(_.isTypedArray([])); 11 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/44_isundefined.js: -------------------------------------------------------------------------------- 1 | /* isUndefined example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.isUndefined(void 0)); 8 | // => true 9 | 10 | console.log(_.isUndefined(null)); 11 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/45_isweakmap.js: -------------------------------------------------------------------------------- 1 | /* isWeakMap example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.isWeakMap(new WeakMap)); 8 | // => true 9 | 10 | console.log(_.isWeakMap(new Map)); 11 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/46_isweakset.js: -------------------------------------------------------------------------------- 1 | /* isWeakSet example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.isWeakSet(new WeakSet)); 8 | // => true 9 | 10 | console.log(_.isWeakSet(new Set)); 11 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/47_lt.js: -------------------------------------------------------------------------------- 1 | /* lt example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.lt(1, 3)); 8 | // => true 9 | 10 | console.log(_.lt(3, 3)); 11 | // => false 12 | 13 | console.log(_.lt(3, 1)); 14 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/48_lte.js: -------------------------------------------------------------------------------- 1 | /* lte example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.lte(1, 3)); 8 | // => true 9 | 10 | console.log(_.lte(3, 3)); 11 | // => true 12 | 13 | console.log(_.lte(3, 1)); 14 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/lang/49_toarray.js: -------------------------------------------------------------------------------- 1 | /* toArray example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.toArray({ 'a': 1, 'b': 2 })); 8 | // => [1, 2] 9 | 10 | console.log(_.toArray('abc')); 11 | // => ['a', 'b', 'c'] 12 | 13 | console.log(_.toArray(1)); 14 | // => [] 15 | 16 | console.log(_.toArray(null)); 17 | // => [] -------------------------------------------------------------------------------- /02-Lodash/examples/lang/50_tofinite.js: -------------------------------------------------------------------------------- 1 | /* toFinite example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.toFinite(3.2)); 8 | // => 3.2 9 | 10 | console.log(_.toFinite(Number.MIN_VALUE)); 11 | // => 5e-324 12 | 13 | console.log(_.toFinite(Infinity)); 14 | // => 1.7976931348623157e+308 15 | 16 | console.log(_.toFinite('3.2')); 17 | // => 3.2 -------------------------------------------------------------------------------- /02-Lodash/examples/lang/51_tointeger.js: -------------------------------------------------------------------------------- 1 | /* toInteger example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.toInteger(3.2)); 8 | // => 3 9 | 10 | console.log(_.toInteger(Number.MIN_VALUE)); 11 | // => 0 12 | 13 | console.log(_.toInteger(Infinity)); 14 | // => 1.7976931348623157e+308 15 | 16 | console.log(_.toInteger('3.2')); 17 | // => 3 -------------------------------------------------------------------------------- /02-Lodash/examples/lang/52_tolength.js: -------------------------------------------------------------------------------- 1 | /* toLength example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | 8 | console.log(_.toLength(3.2)); 9 | // => 3 10 | 11 | console.log(_.toLength(Number.MIN_VALUE)); 12 | // => 0 13 | 14 | console.log(_.toLength(Infinity)); 15 | // => 4294967295 16 | 17 | console.log(_.toLength('3.2')); 18 | // => 3 -------------------------------------------------------------------------------- /02-Lodash/examples/lang/53_tonumber.js: -------------------------------------------------------------------------------- 1 | /* toNumber example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.toNumber(3.2)); 8 | // => 3.2 9 | 10 | console.log(_.toNumber(Number.MIN_VALUE)); 11 | // => 5e-324 12 | 13 | console.log(_.toNumber(Infinity)); 14 | // => Infinity 15 | 16 | console.log(_.toNumber('3.2')); 17 | // => 3.2 -------------------------------------------------------------------------------- /02-Lodash/examples/lang/54_toplainobject.js: -------------------------------------------------------------------------------- 1 | /* toPlainObject example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | function Foo() { 8 | this.b = 2; 9 | } 10 | 11 | Foo.prototype.c = 3; 12 | 13 | console.log(_.assign({ 'a': 1 }, new Foo)); 14 | // => { 'a': 1, 'b': 2 } 15 | 16 | console.log(_.assign({ 'a': 1 }, _.toPlainObject(new Foo))); 17 | // => { 'a': 1, 'b': 2, 'c': 3 } -------------------------------------------------------------------------------- /02-Lodash/examples/lang/55_tosafeinteger.js: -------------------------------------------------------------------------------- 1 | /* toSafeInteger example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.toSafeInteger(3.2)); 8 | // => 3 9 | 10 | console.log(_.toSafeInteger(Number.MIN_VALUE)); 11 | // => 0 12 | 13 | console.log(_.toSafeInteger(Infinity)); 14 | // => 9007199254740991 15 | 16 | console.log(_.toSafeInteger('3.2')); 17 | // => 3 -------------------------------------------------------------------------------- /02-Lodash/examples/lang/56_tostring.js: -------------------------------------------------------------------------------- 1 | /* toString example 2 | */ 3 | 4 | 'use strict'; 5 | var _ = require('../../node_modules/lodash'); 6 | 7 | console.log(_.toString(null)); 8 | // => '' 9 | 10 | console.log(_.toString(-0)); 11 | // => '-0' 12 | 13 | console.log(_.toString([1, 2, 3])); 14 | // => '1,2,3' -------------------------------------------------------------------------------- /02-Lodash/examples/math/01_add.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Add example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.add(36, 46)); -------------------------------------------------------------------------------- /02-Lodash/examples/math/02_ceil.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ceil example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.ceil(8.003)); 9 | // => 9 10 | 11 | console.log(_.ceil(2.00004, 3)); 12 | // => 2.001 13 | 14 | console.log(_.ceil(1235, -3)); 15 | // => 2000 -------------------------------------------------------------------------------- /02-Lodash/examples/math/03_divide.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Divide example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.divide(9, 4)); 9 | // => 2.25 -------------------------------------------------------------------------------- /02-Lodash/examples/math/04_floor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Floor example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.floor(8.003)); 9 | // => 8 10 | 11 | console.log(_.floor(2.00004, 3)); 12 | // => 2 13 | 14 | console.log(_.floor(1235, -3)); 15 | // => 1000 -------------------------------------------------------------------------------- /02-Lodash/examples/math/05_max.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Max example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.max([1, 3, 5, 7])); 9 | // => 7 10 | 11 | console.log(_.max([])); 12 | // => undefined -------------------------------------------------------------------------------- /02-Lodash/examples/math/06_maxby.js: -------------------------------------------------------------------------------- 1 | /** 2 | * MaxBy example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var objects = [{ 'n': 3 }, { 'n': 9 }]; 9 | 10 | console.log(_.maxBy(objects, function(o) { return o.n; })); 11 | // => { 'n': 9 } 12 | 13 | // The `_.property` iteratee shorthand. 14 | console.log(_.maxBy(objects, 'n')); 15 | // => { 'n': 9 } -------------------------------------------------------------------------------- /02-Lodash/examples/math/07_mean.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Mean example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.mean([1, 3, 5, 7])); 9 | // => 4 -------------------------------------------------------------------------------- /02-Lodash/examples/math/08_meanby.js: -------------------------------------------------------------------------------- 1 | /** 2 | * MeanBy example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var objects = [{ 'n': 1 }, { 'n': 3 }, { 'n': 5}, { 'n': 7 }]; 9 | 10 | console.log(_.meanBy(objects, function(o) { return o.n; })); 11 | // => 4 12 | 13 | // The `_.property` iteratee shorthand. 14 | console.log(_.meanBy(objects, 'n')); 15 | // => 4 -------------------------------------------------------------------------------- /02-Lodash/examples/math/09_min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Min example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.min([1, 3, 5, 7])); 9 | // => 1 10 | 11 | console.log(_.min([])); 12 | // => undefined -------------------------------------------------------------------------------- /02-Lodash/examples/math/10_minby.js: -------------------------------------------------------------------------------- 1 | /** 2 | * MinBy example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var objects = [{ 'n': 3 }, { 'n': 9 }]; 9 | 10 | console.log(_.minBy(objects, function(o) { return o.n; })); 11 | // => { 'n': 3 } 12 | 13 | // The `_.property` iteratee shorthand. 14 | console.log(_.minBy(objects, 'n')); 15 | // => { 'n': 3 }' -------------------------------------------------------------------------------- /02-Lodash/examples/math/11_multiply.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Multiply example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.multiply(4, 8)); 9 | // => 32 -------------------------------------------------------------------------------- /02-Lodash/examples/math/12_round.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Round example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.round(8.003)); 9 | // => 8 10 | 11 | console.log(_.round(2.00004, 3)); 12 | // => 2 13 | 14 | console.log(_.round(1235, -3)); 15 | // => 1000 -------------------------------------------------------------------------------- /02-Lodash/examples/math/13_subtract.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Subtract example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.subtract(9, 2)); 9 | // => 2 -------------------------------------------------------------------------------- /02-Lodash/examples/math/14_sum.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sum example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.sum([1, 2, 3, 4])); 9 | // => 10 -------------------------------------------------------------------------------- /02-Lodash/examples/math/15_sumby.js: -------------------------------------------------------------------------------- 1 | /** 2 | * SumBy example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var objects = [{ 'n': 3 }, { 'n': 9 }]; 9 | 10 | console.log(_.sumBy(objects, function(o) { return o.n; })); 11 | // => { 'n': 12 } 12 | 13 | // The `_.property` iteratee shorthand. 14 | console.log(_.sumBy(objects, 'n')); 15 | // => { 'n': 12 }' -------------------------------------------------------------------------------- /02-Lodash/examples/methods/01_ref-lodash-func.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ref lodash function example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.templateSettings.imports._); -------------------------------------------------------------------------------- /02-Lodash/examples/number/01_clamp.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Clamp example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.clamp(-100, -500, 500)); 9 | // => -100 10 | 11 | console.log(_.clamp(10, -5, 5)); 12 | // => 5 -------------------------------------------------------------------------------- /02-Lodash/examples/number/02_inrange.js: -------------------------------------------------------------------------------- 1 | /** 2 | * InRange example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.inRange(3, 2, 4)); 9 | // => true 10 | 11 | console.log(_.inRange(4, 8)); 12 | // => true 13 | 14 | console.log(_.inRange(4, 2)); 15 | // => false 16 | 17 | console.log(_.inRange(2, 2)); 18 | // => false 19 | 20 | console.log(_.inRange(1.2, 2)); 21 | // => true 22 | 23 | console.log(_.inRange(5.2, 4)); 24 | // => false 25 | 26 | console.log(_.inRange(-3, -2, -6)); 27 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/number/03_random.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Random example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.random(0, 9)); 9 | // => an integer between 0 and 9 10 | 11 | console.log(_.random(9)); 12 | // => also an integer between 0 and 9 13 | 14 | console.log(_.random(9, true)); 15 | // => a floating-point number between 0 and 9 16 | 17 | console.log(_.random(1.2, 9.2)); 18 | // => a floating-point number between 1.2 and 9.2 -------------------------------------------------------------------------------- /02-Lodash/examples/object/01_assign.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Assign example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = 1; 10 | } 11 | 12 | function Bar() { 13 | this.c = 3; 14 | } 15 | 16 | Foo.prototype.b = 2; 17 | Bar.prototype.d = 4; 18 | 19 | console.log(_.assign({ 'a': 0 }, new Foo, new Bar)); 20 | // => { 'a': 1, 'c': 3 } -------------------------------------------------------------------------------- /02-Lodash/examples/object/02_assignin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Assign example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = 1; 10 | } 11 | 12 | function Bar() { 13 | this.c = 3; 14 | } 15 | 16 | Foo.prototype.b = 2; 17 | Bar.prototype.d = 4; 18 | 19 | console.log(_.assignIn({ 'a': 0 }, new Foo, new Bar)); 20 | // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } -------------------------------------------------------------------------------- /02-Lodash/examples/object/03_assigninwith.js: -------------------------------------------------------------------------------- 1 | /** 2 | * assignWith example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function customizer(objValue, srcValue) { 9 | return _.isUndefined(objValue) ? srcValue : objValue; 10 | } 11 | 12 | var defaults = _.partialRight(_.assignWith, customizer); 13 | 14 | console.log(defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 })); 15 | // => { 'a': 1, 'b': 2 } -------------------------------------------------------------------------------- /02-Lodash/examples/object/04_assignwith.js: -------------------------------------------------------------------------------- 1 | /** 2 | * difference example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.difference([2, 1, 3], [2, 3, 3])); 9 | // => [1] -------------------------------------------------------------------------------- /02-Lodash/examples/object/05_at.js: -------------------------------------------------------------------------------- 1 | /** 2 | * at example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 9 | 10 | console.log(_.at(object, ['a[0].b.c', 'a[1]'])); 11 | // => [3, 4] -------------------------------------------------------------------------------- /02-Lodash/examples/object/06_create.js: -------------------------------------------------------------------------------- 1 | /** 2 | * create example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Shape() { 9 | this.x = 0; 10 | this.y = 0; 11 | } 12 | 13 | function Circle() { 14 | Shape.call(this); 15 | } 16 | 17 | Circle.prototype = _.create(Shape.prototype, { 18 | 'constructor': Circle 19 | }); 20 | 21 | var circle = new Circle; 22 | console.log(circle instanceof Circle); 23 | // => true 24 | 25 | console.log(circle instanceof Shape); 26 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/object/07_defaults.js: -------------------------------------------------------------------------------- 1 | /** 2 | * defaults example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(__.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 })); 9 | // => { 'a': 1, 'b': 2 } -------------------------------------------------------------------------------- /02-Lodash/examples/object/08_defaultsdeep.js: -------------------------------------------------------------------------------- 1 | /** 2 | * defaultsDeep example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } })); 9 | // => { 'a': { 'b': 2, 'c': 3 } } -------------------------------------------------------------------------------- /02-Lodash/examples/object/09_entries.js: -------------------------------------------------------------------------------- 1 | /** 2 | * entries example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | 9 | function Foo() { 10 | this.a = 1; 11 | this.b = 2; 12 | } 13 | 14 | Foo.prototype.c = 3; 15 | 16 | console.log(_.toPairs(new Foo)); 17 | // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) -------------------------------------------------------------------------------- /02-Lodash/examples/object/10_entriesin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * toPairsIn example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | 9 | function Foo() { 10 | this.a = 1; 11 | this.b = 2; 12 | } 13 | 14 | Foo.prototype.c = 3; 15 | 16 | console.log(_.toPairsIn(new Foo)); 17 | // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) -------------------------------------------------------------------------------- /02-Lodash/examples/object/11_extend.js: -------------------------------------------------------------------------------- 1 | /** 2 | * assignIn example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = 1; 10 | } 11 | 12 | function Bar() { 13 | this.c = 3; 14 | } 15 | 16 | Foo.prototype.b = 2; 17 | Bar.prototype.d = 4; 18 | 19 | console.log(_.assignIn({ 'a': 0 }, new Foo, new Bar)); 20 | // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } -------------------------------------------------------------------------------- /02-Lodash/examples/object/12_extendwith.js: -------------------------------------------------------------------------------- 1 | /** 2 | * extendwith example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | 9 | function customizer(objValue, srcValue) { 10 | return _.isUndefined(objValue) ? srcValue : objValue; 11 | } 12 | 13 | var defaults = _.partialRight(_.assignInWith, customizer); 14 | 15 | console.log(defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 })); 16 | // => { 'a': 1, 'b': 2 } 17 | 18 | -------------------------------------------------------------------------------- /02-Lodash/examples/object/13_findkey.js: -------------------------------------------------------------------------------- 1 | /** 2 | * findKey example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var users = { 9 | 'barney': { 'age': 36, 'active': true }, 10 | 'fred': { 'age': 40, 'active': false }, 11 | 'pebbles': { 'age': 1, 'active': true } 12 | }; 13 | 14 | console.log(_.findKey(users, function(o) { return o.age < 40; })); 15 | // => 'barney' (iteration order is not guaranteed) 16 | 17 | // The `_.matches` iteratee shorthand. 18 | console.log(_.findKey(users, { 'age': 1, 'active': true })); 19 | // => 'pebbles' 20 | 21 | // The `_.matchesProperty` iteratee shorthand. 22 | console.log(_.findKey(users, ['active', false])); 23 | // => 'fred' 24 | 25 | // The `_.property` iteratee shorthand. 26 | console.log(_.findKey(users, 'active')); 27 | // => 'barney' -------------------------------------------------------------------------------- /02-Lodash/examples/object/14_findlastkey.js: -------------------------------------------------------------------------------- 1 | /** 2 | * findLastKey example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | var users = { 8 | 'barney': { 'age': 36, 'active': true }, 9 | 'fred': { 'age': 40, 'active': false }, 10 | 'pebbles': { 'age': 1, 'active': true } 11 | }; 12 | 13 | console.log(__.findLastKey(users, function(o) { return o.age < 40; })); 14 | // => returns 'pebbles' assuming `_.findKey` returns 'barney' 15 | 16 | // The `_.matches` iteratee shorthand. 17 | console.log(__.findLastKey(users, { 'age': 36, 'active': true })); 18 | // => 'barney' 19 | 20 | // The `_.matchesProperty` iteratee shorthand. 21 | console.log(__.findLastKey(users, ['active', false])); 22 | // => 'fred' 23 | 24 | // The `_.property` iteratee shorthand. 25 | console.log(__.findLastKey(users, 'active')); 26 | // => 'pebbles' -------------------------------------------------------------------------------- /02-Lodash/examples/object/15_forin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * forIn example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | function Foo() { 8 | this.a = 1; 9 | this.b = 2; 10 | } 11 | 12 | Foo.prototype.c = 3; 13 | 14 | _.forIn(new Foo, function(value, key) { 15 | console.log(key); 16 | }); 17 | // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). -------------------------------------------------------------------------------- /02-Lodash/examples/object/16_forinright.js: -------------------------------------------------------------------------------- 1 | /** 2 | * forInRight example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = 1; 10 | this.b = 2; 11 | } 12 | 13 | Foo.prototype.c = 3; 14 | 15 | _.forInRight(new Foo, function(value, key) { 16 | console.log(key); 17 | }); 18 | // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. -------------------------------------------------------------------------------- /02-Lodash/examples/object/17_forown.js: -------------------------------------------------------------------------------- 1 | /** 2 | * forOwn example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = 1; 10 | this.b = 2; 11 | } 12 | 13 | Foo.prototype.c = 3; 14 | 15 | _.forOwn(new Foo, function(value, key) { 16 | console.log(key); 17 | }); 18 | // => Logs 'a' then 'b' (iteration order is not guaranteed). -------------------------------------------------------------------------------- /02-Lodash/examples/object/18_forownright.js: -------------------------------------------------------------------------------- 1 | /** 2 | * forOwnRight example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = 1; 10 | this.b = 2; 11 | } 12 | 13 | Foo.prototype.c = 3; 14 | 15 | _.forOwnRight(new Foo, function(value, key) { 16 | console.log(key); 17 | }); 18 | // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. -------------------------------------------------------------------------------- /02-Lodash/examples/object/19_functions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * functions example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = _.constant('a'); 10 | this.b = _.constant('b'); 11 | } 12 | 13 | Foo.prototype.c = _.constant('c'); 14 | 15 | console.log(_.functions(new Foo)); 16 | // => ['a', 'b'] 17 | -------------------------------------------------------------------------------- /02-Lodash/examples/object/20_functionsin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * functionsIn example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = _.constant('a'); 10 | this.b = _.constant('b'); 11 | } 12 | 13 | Foo.prototype.c = _.constant('c'); 14 | 15 | console.log(_.functionsIn(new Foo)); 16 | // => ['a', 'b', 'c'] -------------------------------------------------------------------------------- /02-Lodash/examples/object/21_get.js: -------------------------------------------------------------------------------- 1 | /** 2 | * get example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': [{ 'b': { 'c': 3 } }] }; 9 | 10 | console.log(_.get(object, 'a[0].b.c')); 11 | // => 3 12 | 13 | console.log(_.get(object, ['a', '0', 'b', 'c'])); 14 | // => 3 15 | 16 | console.log(_.get(object, 'a.b.c', 'default')); 17 | // => 'default' -------------------------------------------------------------------------------- /02-Lodash/examples/object/22_has.js: -------------------------------------------------------------------------------- 1 | /** 2 | * has example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': { 'b': 2 } }; 9 | var other = _.create({ 'a': _.create({ 'b': 2 }) }); 10 | 11 | console.log(_.has(object, 'a')); 12 | // => true 13 | 14 | console.log(_.has(object, 'a.b')); 15 | // => true 16 | 17 | console.log(_.has(object, ['a', 'b'])); 18 | // => true 19 | 20 | console.log(_.has(other, 'a')); 21 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/object/23_hasin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * hasIn example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = _.create({ 'a': _.create({ 'b': 2 }) }); 9 | 10 | console.log(_.hasIn(object, 'a')); 11 | // => true 12 | 13 | console.log(_.hasIn(object, 'a.b')); 14 | // => true 15 | 16 | console.log(_.hasIn(object, ['a', 'b'])); 17 | // => true 18 | 19 | console.log(_.hasIn(object, 'b')); 20 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/object/24_invert.js: -------------------------------------------------------------------------------- 1 | /** 2 | * invert example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': 1, 'b': 2, 'c': 1 }; 9 | 10 | console.log(_.invert(object)); 11 | // => { '1': 'c', '2': 'b' } -------------------------------------------------------------------------------- /02-Lodash/examples/object/25_invertby.js: -------------------------------------------------------------------------------- 1 | /** 2 | * invertBy example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': 1, 'b': 2, 'c': 1 }; 9 | 10 | console.log(_.invertBy(object)); 11 | // => { '1': ['a', 'c'], '2': ['b'] } 12 | 13 | console.log(_.invertBy(object, function(value) { 14 | return 'group' + value; 15 | })); 16 | // => { 'group1': ['a', 'c'], 'group2': ['b'] } -------------------------------------------------------------------------------- /02-Lodash/examples/object/26_invoke.js: -------------------------------------------------------------------------------- 1 | /** 2 | * invoke example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 9 | 10 | console.log(_.invoke(object, 'a[0].b.c.slice', 1, 3)); 11 | // => [2, 3] -------------------------------------------------------------------------------- /02-Lodash/examples/object/27_keys.js: -------------------------------------------------------------------------------- 1 | /** 2 | * keys example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = 1; 10 | this.b = 2; 11 | } 12 | 13 | Foo.prototype.c = 3; 14 | 15 | console.log(_.keys(new Foo)); 16 | // => ['a', 'b'] (iteration order is not guaranteed) 17 | 18 | console.log(_.keys('hi')); 19 | // => ['0', '1'] -------------------------------------------------------------------------------- /02-Lodash/examples/object/28_keysin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * keysIn example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = 1; 10 | this.b = 2; 11 | } 12 | 13 | Foo.prototype.c = 3; 14 | 15 | console.log(_.keysIn(new Foo)); 16 | // => ['a', 'b', 'c'] (iteration order is not guaranteed) -------------------------------------------------------------------------------- /02-Lodash/examples/object/29_mapkeys.js: -------------------------------------------------------------------------------- 1 | /** 2 | * mapKeys example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 9 | return key + value; 10 | })); 11 | // => { 'a1': 1, 'b2': 2 } -------------------------------------------------------------------------------- /02-Lodash/examples/object/30_mapvalues.js: -------------------------------------------------------------------------------- 1 | /** 2 | * mapValues example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var users = { 9 | 'fred': { 'user': 'fred', 'age': 40 }, 10 | 'pebbles': { 'user': 'pebbles', 'age': 1 } 11 | }; 12 | 13 | console.log(_.mapValues(users, function(o) { return o.age; })); 14 | // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 15 | 16 | // The `_.property` iteratee shorthand. 17 | console.log(_.mapValues(users, 'age')); 18 | // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) -------------------------------------------------------------------------------- /02-Lodash/examples/object/31_merge.js: -------------------------------------------------------------------------------- 1 | /** 2 | * merge example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 9 | 'a': [{ 'b': 2 }, { 'd': 4 }] 10 | }; 11 | 12 | var other = { 13 | 'a': [{ 'c': 3 }, { 'e': 5 }] 14 | }; 15 | 16 | console.log(_.merge(object, other)); 17 | // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } -------------------------------------------------------------------------------- /02-Lodash/examples/object/32_mergewith.js: -------------------------------------------------------------------------------- 1 | /** 2 | * mergeWith example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function customizer(objValue, srcValue) { 9 | if (_.isArray(objValue)) { 10 | return objValue.concat(srcValue); 11 | } 12 | } 13 | 14 | var object = { 'a': [1], 'b': [2] }; 15 | var other = { 'a': [3], 'b': [4] }; 16 | 17 | console.log(_.mergeWith(object, other, customizer)); 18 | // => { 'a': [1, 3], 'b': [2, 4] } -------------------------------------------------------------------------------- /02-Lodash/examples/object/33_omit.js: -------------------------------------------------------------------------------- 1 | /** 2 | * omit example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': 1, 'b': '2', 'c': 3 }; 9 | 10 | console.log(_.omit(object, ['a', 'c'])); 11 | // => { 'b': '2' } -------------------------------------------------------------------------------- /02-Lodash/examples/object/34_omitby.js: -------------------------------------------------------------------------------- 1 | /** 2 | * omitBy example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': 1, 'b': '2', 'c': 3 }; 9 | 10 | console.log(_.omitBy(object, _.isNumber)); 11 | // => { 'b': '2' } -------------------------------------------------------------------------------- /02-Lodash/examples/object/35_pick.js: -------------------------------------------------------------------------------- 1 | /** 2 | * pick example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': 1, 'b': '2', 'c': 3 }; 9 | 10 | console.log(_.pick(object, ['a', 'c'])); 11 | // => { 'a': 1, 'c': 3 } -------------------------------------------------------------------------------- /02-Lodash/examples/object/36_pickby.js: -------------------------------------------------------------------------------- 1 | /** 2 | * pickBy example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': 1, 'b': '2', 'c': 3 }; 9 | 10 | console.log(_.pickBy(object, _.isNumber)); 11 | // => { 'a': 1, 'c': 3 } -------------------------------------------------------------------------------- /02-Lodash/examples/object/37_result.js: -------------------------------------------------------------------------------- 1 | /** 2 | * result example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 9 | 10 | console.log(_.result(object, 'a[0].b.c1')); 11 | // => 3 12 | 13 | console.log(_.result(object, 'a[0].b.c2')); 14 | // => 4 15 | 16 | console.log(_.result(object, 'a[0].b.c3', 'default')); 17 | // => 'default' 18 | 19 | console.log(_.result(object, 'a[0].b.c3', _.constant('default'))); 20 | // => 'default' -------------------------------------------------------------------------------- /02-Lodash/examples/object/38_set.js: -------------------------------------------------------------------------------- 1 | /** 2 | * set example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': [{ 'b': { 'c': 3 } }] }; 9 | 10 | _.set(object, 'a[0].b.c', 4); 11 | console.log(object.a[0].b.c); 12 | // => 4 13 | 14 | _.set(object, ['x', '0', 'y', 'z'], 5); 15 | console.log(object.x[0].y.z); 16 | // => 5 -------------------------------------------------------------------------------- /02-Lodash/examples/object/39_setwith.js: -------------------------------------------------------------------------------- 1 | /** 2 | * setWith example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = {}; 9 | 10 | console.log(_.setWith(object, '[0][1]', 'a', Object)); 11 | // => { '0': { '1': 'a' } } -------------------------------------------------------------------------------- /02-Lodash/examples/object/40_topairs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * toPairs example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = 1; 10 | this.b = 2; 11 | } 12 | 13 | Foo.prototype.c = 3; 14 | 15 | console.log(_.toPairs(new Foo)); 16 | // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) -------------------------------------------------------------------------------- /02-Lodash/examples/object/41_topairsin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * toPairsIn example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = 1; 10 | this.b = 2; 11 | } 12 | 13 | Foo.prototype.c = 3; 14 | 15 | console.log(_.toPairsIn(new Foo)); 16 | // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) -------------------------------------------------------------------------------- /02-Lodash/examples/object/42_transform.js: -------------------------------------------------------------------------------- 1 | /** 2 | * transform example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.transform([2, 3, 4], function(result, n) { 9 | result.push(n *= n); 10 | return n % 2 == 0; 11 | }, [])); 12 | // => [4, 9] 13 | 14 | console.log(_.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 15 | (result[value] || (result[value] = [])).push(key); 16 | }, {})); 17 | // => { '1': ['a', 'c'], '2': ['b'] } -------------------------------------------------------------------------------- /02-Lodash/examples/object/43_unset.js: -------------------------------------------------------------------------------- 1 | /** 2 | * unset example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': [{ 'b': { 'c': 7 } }] }; 9 | _.unset(object, 'a[0].b.c'); 10 | // => true 11 | 12 | console.log(object); 13 | // => { 'a': [{ 'b': {} }] }; 14 | 15 | _.unset(object, ['a', '0', 'b', 'c']); 16 | // => true 17 | 18 | console.log(object); 19 | // => { 'a': [{ 'b': {} }] }; -------------------------------------------------------------------------------- /02-Lodash/examples/object/44_update.js: -------------------------------------------------------------------------------- 1 | /** 2 | * update example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': [{ 'b': { 'c': 3 } }] }; 9 | 10 | _.update(object, 'a[0].b.c', function(n) { return n * n; }); 11 | console.log(object.a[0].b.c); 12 | // => 9 13 | 14 | _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 15 | console.log(object.x[0].y.z); 16 | // => 0 -------------------------------------------------------------------------------- /02-Lodash/examples/object/45_updatewith.js: -------------------------------------------------------------------------------- 1 | /** 2 | * updateWith example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = {}; 9 | 10 | console.log(_.updateWith(object, '[0][1]', _.constant('a'), Object)); 11 | // => { '0': { '1': 'a' } } -------------------------------------------------------------------------------- /02-Lodash/examples/object/46_values.js: -------------------------------------------------------------------------------- 1 | /** 2 | * values example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = 1; 10 | this.b = 2; 11 | } 12 | 13 | Foo.prototype.c = 3; 14 | 15 | console.log(_.values(new Foo)); 16 | // => [1, 2] (iteration order is not guaranteed) 17 | 18 | console.log(_.values('hi')); 19 | // => ['h', 'i'] -------------------------------------------------------------------------------- /02-Lodash/examples/object/47_valuesin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * valuesIn example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function Foo() { 9 | this.a = 1; 10 | this.b = 2; 11 | } 12 | 13 | Foo.prototype.c = 3; 14 | 15 | console.log(_.valuesIn(new Foo)); 16 | // => [1, 2, 3] (iteration order is not guaranteed) -------------------------------------------------------------------------------- /02-Lodash/examples/properties/01_version.js: -------------------------------------------------------------------------------- 1 | /** 2 | * VERSION example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.VERSION); -------------------------------------------------------------------------------- /02-Lodash/examples/properties/02_templatesettings.js: -------------------------------------------------------------------------------- 1 | /** 2 | * templateSettings example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.templateSettings); -------------------------------------------------------------------------------- /02-Lodash/examples/properties/03_templatesettings-escape.js: -------------------------------------------------------------------------------- 1 | /** 2 | * templateSettings-escape example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.templateSettings.escape); -------------------------------------------------------------------------------- /02-Lodash/examples/properties/04_templatesettings-evaluate.js: -------------------------------------------------------------------------------- 1 | /** 2 | * templateSettings-evaluate example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.templateSettings.evaluate); -------------------------------------------------------------------------------- /02-Lodash/examples/properties/05_templatesettings-imports.js: -------------------------------------------------------------------------------- 1 | /** 2 | * templateSettings-imports example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.templateSettings.imports); -------------------------------------------------------------------------------- /02-Lodash/examples/properties/06_templatesettings-interpolate.js: -------------------------------------------------------------------------------- 1 | /** 2 | * templateSettings-interpolate example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.templateSettings.interpolate); -------------------------------------------------------------------------------- /02-Lodash/examples/properties/07_templatesettings-variable.js: -------------------------------------------------------------------------------- 1 | /** 2 | * templateSettings-variable example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.templateSettings.variable); -------------------------------------------------------------------------------- /02-Lodash/examples/seq/01_lodash.js: -------------------------------------------------------------------------------- 1 | /** 2 | * lodash example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function square(n) { 9 | return n * n; 10 | } 11 | 12 | var wrapped = _([1, 2, 3]); 13 | 14 | // Returns an unwrapped value. 15 | console.log(wrapped.reduce(_.add)); 16 | // => 6 17 | 18 | // Returns a wrapped value. 19 | var squares = wrapped.map(square); 20 | 21 | console.log(_.isArray(squares)); 22 | // => false 23 | 24 | console.log(_.isArray(squares.value())); 25 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/seq/02_chain.js: -------------------------------------------------------------------------------- 1 | /** 2 | * chain example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var users = [ 9 | { 'user': 'barney', 'age': 36 }, 10 | { 'user': 'fred', 'age': 40 }, 11 | { 'user': 'pebbles', 'age': 1 } 12 | ]; 13 | 14 | var youngest = _ 15 | .chain(users) 16 | .sortBy('age') 17 | .map(function(o) { 18 | return o.user + ' is ' + o.age; 19 | }) 20 | .head() 21 | .value(); 22 | console.log(youngest); 23 | // => 'pebbles is 1' -------------------------------------------------------------------------------- /02-Lodash/examples/seq/03_tap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * tap example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_([1, 2, 3]) 9 | .tap(function(array) { 10 | // Mutate input array. 11 | array.pop(); 12 | }) 13 | .reverse() 14 | .value()); 15 | // => [2, 1] -------------------------------------------------------------------------------- /02-Lodash/examples/seq/04_thru.js: -------------------------------------------------------------------------------- 1 | /** 2 | * thru example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_(' abc ') 9 | .chain() 10 | .trim() 11 | .thru(function(value) { 12 | return [value]; 13 | }) 14 | .value()); 15 | // => ['abc'] -------------------------------------------------------------------------------- /02-Lodash/examples/seq/05_prototype-symbol.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Symbol example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var wrapped = _([1, 2]); 9 | 10 | console.log(wrapped[Symbol.iterator]() === wrapped); 11 | // => true 12 | 13 | console.log(Array.from(wrapped)); 14 | // => [1, 2] -------------------------------------------------------------------------------- /02-Lodash/examples/seq/06_prototype-at.js: -------------------------------------------------------------------------------- 1 | /** 2 | * at example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 9 | 10 | console.log(_(object).at(['a[0].b.c', 'a[1]']).value()); 11 | // => [3, 4] -------------------------------------------------------------------------------- /02-Lodash/examples/seq/07_prototype-chain.js: -------------------------------------------------------------------------------- 1 | /** 2 | * chain example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var users = [ 9 | { 'user': 'barney', 'age': 36 }, 10 | { 'user': 'fred', 'age': 40 } 11 | ]; 12 | 13 | // A sequence without explicit chaining. 14 | console.log(_(users).head()); 15 | // => { 'user': 'barney', 'age': 36 } 16 | 17 | // A sequence with explicit chaining. 18 | console.log(_(users) 19 | .chain() 20 | .head() 21 | .pick('user') 22 | .value()); 23 | // => { 'user': 'barney' } -------------------------------------------------------------------------------- /02-Lodash/examples/seq/08_prototype-commit.js: -------------------------------------------------------------------------------- 1 | /** 2 | * commit example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var array = [1, 2]; 9 | var wrapped = _(array).push(3); 10 | 11 | console.log(array); 12 | // => [1, 2] 13 | 14 | wrapped = wrapped.commit(); 15 | console.log(array); 16 | // => [1, 2, 3] 17 | 18 | wrapped.last(); 19 | // => 3 20 | 21 | console.log(array); 22 | // => [1, 2, 3] -------------------------------------------------------------------------------- /02-Lodash/examples/seq/09_prototype-next.js: -------------------------------------------------------------------------------- 1 | /** 2 | * next example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var wrapped = _([1, 2]); 9 | 10 | console.log(wrapped.next()); 11 | // => { 'done': false, 'value': 1 } 12 | 13 | console.log(wrapped.next()); 14 | // => { 'done': false, 'value': 2 } 15 | 16 | console.log(wrapped.next()); 17 | // => { 'done': true, 'value': undefined } -------------------------------------------------------------------------------- /02-Lodash/examples/seq/10_prototype-plant.js: -------------------------------------------------------------------------------- 1 | /** 2 | * plant example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function square(n) { 9 | return n * n; 10 | } 11 | 12 | var wrapped = _([1, 2]).map(square); 13 | var other = wrapped.plant([3, 4]); 14 | 15 | console.log(other.value()); 16 | // => [9, 16] 17 | 18 | console.log(wrapped.value()); 19 | // => [1, 4] -------------------------------------------------------------------------------- /02-Lodash/examples/seq/11_prototype-reverse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * reverse example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var array = [1, 2, 3]; 9 | 10 | console.log(_(array).reverse().value()); 11 | // => [3, 2, 1] 12 | 13 | console.log(array); 14 | // => [3, 2, 1] -------------------------------------------------------------------------------- /02-Lodash/examples/seq/12_prototype-json.js: -------------------------------------------------------------------------------- 1 | /** 2 | * value example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_([1, 2, 3]).value()); 9 | // => [1, 2, 3] -------------------------------------------------------------------------------- /02-Lodash/examples/seq/13_prototype-value.js: -------------------------------------------------------------------------------- 1 | /** 2 | * value example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_([1, 2, 3]).value()); 9 | // => [1, 2, 3] -------------------------------------------------------------------------------- /02-Lodash/examples/seq/14_prototype-valueof.js: -------------------------------------------------------------------------------- 1 | /** 2 | * value example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_([1, 2, 3]).value()); 9 | // => [1, 2, 3] -------------------------------------------------------------------------------- /02-Lodash/examples/string/01_camelcase.js: -------------------------------------------------------------------------------- 1 | /** 2 | * CamelCase example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.camelCase('Foot Ball')); 9 | // => 'footBall' 10 | 11 | console.log(_.camelCase('--foot-ball--')); 12 | // => 'footBall' 13 | 14 | console.log(_.camelCase('__FOOT_BALL__')); 15 | // => 'footBall' -------------------------------------------------------------------------------- /02-Lodash/examples/string/02_capitalize.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Capitalize example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.capitalize('SUDHEER')); 9 | // => 'Fred' -------------------------------------------------------------------------------- /02-Lodash/examples/string/03_deburr.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Deburr example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.deburr('Südheer Jŏnna')); 9 | // => 'Fred' -------------------------------------------------------------------------------- /02-Lodash/examples/string/04_endswith.js: -------------------------------------------------------------------------------- 1 | /** 2 | * EndsWith example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.endsWith('sudheer', 'r')); 9 | // => true 10 | 11 | console.log(_.endsWith('sudheer', 'h')); 12 | // => false 13 | 14 | console.log(_.endsWith('sudheer', 'h', 4)); 15 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/string/05_escape.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Escape example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.escape('Apples,Oranges, & Mangoes')); 9 | // => 'Apples,Oranges, & Mangoes' -------------------------------------------------------------------------------- /02-Lodash/examples/string/06_escaperegexp.js: -------------------------------------------------------------------------------- 1 | /** 2 | * EscapeRegExp example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.escapeRegExp('[sudheerjonna](https://sudheerjonna.com/)')); 9 | // => '\[sudheerjonna\]\(https://sudheerjonna\.com/\)' -------------------------------------------------------------------------------- /02-Lodash/examples/string/07_kebabcase.js: -------------------------------------------------------------------------------- 1 | /** 2 | * KebabCase example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.kebabCase('Foot Ball')); 9 | // => 'foot-ball' 10 | 11 | console.log(_.kebabCase('footBall')); 12 | // => 'foot-ball' 13 | 14 | console.log(_.kebabCase('__FOOT_BALL__')); 15 | // => 'foot-ball' -------------------------------------------------------------------------------- /02-Lodash/examples/string/08_lowercase.js: -------------------------------------------------------------------------------- 1 | /** 2 | * LowerCase example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.lowerCase('Foot Ball')); 9 | // => 'foot ball' 10 | 11 | console.log(_.lowerCase('footBall')); 12 | // => 'foot ball' 13 | 14 | console.log(_.lowerCase('__FOOT_BALL__')); 15 | // => 'foot ball' -------------------------------------------------------------------------------- /02-Lodash/examples/string/09_lowerfirst.js: -------------------------------------------------------------------------------- 1 | /** 2 | * LowerFirst example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.lowerFirst('Sudheer')); 9 | // => 'sudheer' 10 | 11 | console.log(_.lowerFirst('SUDHEER')); 12 | // => 'sUDHEER' -------------------------------------------------------------------------------- /02-Lodash/examples/string/10_pad.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Pad example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.pad('jonna', 9)); 9 | // => ' jonna ' 10 | 11 | console.log(_.pad('jonna', 10, '=@')); 12 | // => '=@jonna=@=' 13 | 14 | console.log(_.pad('sudh', 10)); 15 | // => ' sudh ' -------------------------------------------------------------------------------- /02-Lodash/examples/string/11_padend.js: -------------------------------------------------------------------------------- 1 | /** 2 | * PadEnd example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.padEnd('jonna', 9)); 9 | // => 'jonna ' 10 | 11 | console.log(_.padEnd('jonna', 10, '=@')); 12 | // => 'jonna=@=@=' 13 | 14 | console.log(_.padEnd('sudh', 10)); 15 | // => 'sudh ' -------------------------------------------------------------------------------- /02-Lodash/examples/string/12_padstart.js: -------------------------------------------------------------------------------- 1 | /** 2 | * PadStart example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.padStart('jonna', 9)); 9 | // => ' jonna ' 10 | 11 | console.log(_.padStart('jonna', 10, '=@')); 12 | // => '=@jonna=@=' 13 | 14 | console.log(_.padStart('sudh', 10)); 15 | // => ' sudh ' -------------------------------------------------------------------------------- /02-Lodash/examples/string/13_parseint.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ParseInt example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.parseInt('05')); 9 | // => 5 10 | 11 | console.log(_.map(['04', '05','03', '02', '04'], _.parseInt)); 12 | // => [04, 05, 03, 02, 04] -------------------------------------------------------------------------------- /02-Lodash/examples/string/14_repeat.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Repeat example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.repeat('@', 5)); 9 | // => '@@@@@' 10 | 11 | console.log(_.repeat('sudheer', 2)); 12 | // => 'sudheersudheer' 13 | 14 | console.log(_.repeat('sudheer', 0)); 15 | // => '' -------------------------------------------------------------------------------- /02-Lodash/examples/string/15_replace.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Replace example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.replace('Hello JavaScript', 'JavaScript', 'Lodash')); 9 | // => 'Hello Lodash' -------------------------------------------------------------------------------- /02-Lodash/examples/string/16_snakecase.js: -------------------------------------------------------------------------------- 1 | /** 2 | * SnakeCase example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.snakeCase('Foot Ball')); 9 | // => 'foot_ball' 10 | 11 | console.log(_.snakeCase('footBall')); 12 | // => 'foot_ball' 13 | 14 | console.log(_.snakeCase('--FOOT-BALL--')); 15 | // => 'foot_ball' -------------------------------------------------------------------------------- /02-Lodash/examples/string/17_split.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Split example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.split('s-u-d-h-e-e-r', '-', 4)); 9 | // => ['s', 'u', 'd', 'h'] -------------------------------------------------------------------------------- /02-Lodash/examples/string/18_startcase.js: -------------------------------------------------------------------------------- 1 | /** 2 | * StartCase example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | 9 | console.log(_.startCase('--foot-ball--')); 10 | // => 'Foot Ball' 11 | 12 | console.log(_.startCase('footBall')); 13 | // => 'Foot Ball' 14 | 15 | console.log(_.startCase('__FOOT_BALL__')); 16 | // => 'FOOT BALL' -------------------------------------------------------------------------------- /02-Lodash/examples/string/19_startswith.js: -------------------------------------------------------------------------------- 1 | /** 2 | * StartsWith example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.startsWith('lodash', 'l')); 9 | // => true 10 | 11 | console.log(_.startsWith('lodash', 'd')); 12 | // => false 13 | 14 | console.log(_.startsWith('lodash', 's', 4)); 15 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/string/20_template.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Template example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | 9 | // Use the "interpolate" delimiter to create a compiled template. 10 | var compiled = _.template('hello <%= js %>!'); 11 | console.log(compiled({ 'js': 'lodash' })); 12 | // => 'hello lodash!' 13 | 14 | // Use the internal `print` function in "evaluate" delimiters. 15 | 16 | var compiled = _.template('<% print("hello " + js); %>!'); 17 | console.log(compiled({ 'js': 'lodash' })); 18 | // => 'hello lodash!' -------------------------------------------------------------------------------- /02-Lodash/examples/string/21_tolower.js: -------------------------------------------------------------------------------- 1 | /** 2 | * To Lower example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.toLower('--Foot-Ball--')); 9 | // => '--foot-ball--' 10 | 11 | console.log(_.toLower('footBall')); 12 | // => 'football' 13 | 14 | console.log(_.toLower('__FOOT_BALL__')); 15 | // => '__foot_ball__' -------------------------------------------------------------------------------- /02-Lodash/examples/string/22_toupper.js: -------------------------------------------------------------------------------- 1 | /** 2 | * To Upper example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.toUpper('--Foot-Ball--')); 9 | // => '--FOOT-BALL--' 10 | 11 | console.log(_.toUpper('footBall')); 12 | // => 'FOOTBALL' 13 | 14 | console.log(_.toUpper('__FOOT_BALL__')); 15 | // => '__FOOT_BALL__' -------------------------------------------------------------------------------- /02-Lodash/examples/string/23_trim.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Trim example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.trim(' lodash ')); 9 | // => 'lodash' 10 | 11 | console.log(_.trim('-_-lodash-_-', '_-')); 12 | // => 'lodash' 13 | 14 | console.log(_.map([' lodash ', ' utility '], _.trim)); 15 | // => ['lodash', 'utility'] -------------------------------------------------------------------------------- /02-Lodash/examples/string/24_trimend.js: -------------------------------------------------------------------------------- 1 | /** 2 | * TrimEnd example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.trimEnd(' lodash ')); 9 | // => ' lodash' 10 | 11 | console.log(_.trimEnd('-_-lodash-_-', '_-')); 12 | // => '-_-lodash' 13 | 14 | console.log(_.map([' lodash ', ' utility '], _.trimEnd)); 15 | // => [' lodash', ' utility'] -------------------------------------------------------------------------------- /02-Lodash/examples/string/25_trimstart.js: -------------------------------------------------------------------------------- 1 | /** 2 | * TrimStart example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.trimStart(' lodash ')); 9 | // => ' lodash' 10 | 11 | console.log(_.trimStart('-_-lodash-_-', '_-')); 12 | // => '-_-lodash' 13 | 14 | console.log(_.map([' lodash ', ' utility '], _.trimStart)); 15 | // => [' lodash', ' utility'] -------------------------------------------------------------------------------- /02-Lodash/examples/string/26_truncate.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Truncate example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.truncate('Hello lodash fans there, lets enjoy JS')); 9 | // => 'Hello lodash fans there, le...' 10 | 11 | console.log(_.truncate('Hello lodash fans there, lets enjoy JS', { 12 | 'length': 24, 13 | 'separator': ' ' 14 | })); 15 | // => 'Hello lodash fans...' 16 | 17 | console.log(_.truncate('Hello lodash fans there, lets enjoy JS', { 18 | 'length': 24, 19 | 'separator': /,? +/ 20 | })); 21 | // => 'Hello lodash fans...' 22 | 23 | console.log(_.truncate('Hello lodash fans there, lets enjoy JS', { 24 | 'omission': ' [...]' 25 | })); 26 | // => 'Hello lodash fans there, [...]' -------------------------------------------------------------------------------- /02-Lodash/examples/string/27_unescape.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Unescape example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.unescape('Hello, lodash, & devs')); 9 | // => 'Hello, lodash, & devs' -------------------------------------------------------------------------------- /02-Lodash/examples/string/28_uppercase.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Upper Case example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.upperCase('--foot-ball')); 9 | // => 'FOOT BALL' 10 | 11 | console.log(_.upperCase('footBall')); 12 | // => 'FOOT BALL' 13 | 14 | console.log(_.upperCase('__foot_ball__')); 15 | // => 'FOOT BALL' -------------------------------------------------------------------------------- /02-Lodash/examples/string/29_upperfirst.js: -------------------------------------------------------------------------------- 1 | /** 2 | * UpperFirst example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.upperFirst('lodash')); 9 | // => 'Lodash' 10 | 11 | console.log(_.upperFirst('LODASH')); 12 | // => 'LODASH' -------------------------------------------------------------------------------- /02-Lodash/examples/string/30_words.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Words example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.words('hi, lodash, & devs')); 9 | // => ['hi', 'lodash', 'devs'] 10 | 11 | console.log(_.words('hi, lodash, & devs', /[^, ]+/g)); 12 | // => ['hi', 'lodash', '&', 'devs'] -------------------------------------------------------------------------------- /02-Lodash/examples/util/01_attempt.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Attempt example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | // Avoid throwing errors for invalid selectors. 9 | var elements = _.attempt(function(selector) { 10 | return document.querySelectorAll(selector); 11 | }, '>_>'); 12 | 13 | //console.log(elements); 14 | 15 | if (_.isError(elements)) { 16 | elements = []; 17 | } -------------------------------------------------------------------------------- /02-Lodash/examples/util/02_bindall.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Attempt example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | var jQuery = require('../../node_modules/jQuery'); 8 | const jsdom = require("jsdom"); 9 | const { JSDOM } = jsdom; 10 | 11 | var view = { 12 | 'label': 'docs', 13 | 'click': function() { 14 | console.log('clicked ' + this.label); 15 | } 16 | }; 17 | 18 | const dom = new JSDOM(` 19 | 20 | `); 21 | 22 | var element = dom.window.document.body.children[0]; 23 | 24 | _.bindAll(view, ['click']); 25 | jQuery(element).on('click', view.click); 26 | // => Logs 'clicked docs' when clicked. -------------------------------------------------------------------------------- /02-Lodash/examples/util/03_cond.js: -------------------------------------------------------------------------------- 1 | /** 2 | * cond example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var func = _.cond([ 9 | [_.matches({ 'a': 1 }), _.constant('matches A')], 10 | [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 11 | [_.stubTrue, _.constant('no match')] 12 | ]); 13 | 14 | console.log(func({ 'a': 1, 'b': 2 })); 15 | // => 'matches A' 16 | 17 | console.log(func({ 'a': 0, 'b': 1 })); 18 | // => 'matches B' 19 | 20 | console.log(func({ 'a': '1', 'b': '2' })); 21 | // => 'no match' 22 | 23 | -------------------------------------------------------------------------------- /02-Lodash/examples/util/04_conforms.js: -------------------------------------------------------------------------------- 1 | /** 2 | * conforms example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var objects = [ 9 | { 'a': 2, 'b': 1 }, 10 | { 'a': 1, 'b': 2 } 11 | ]; 12 | 13 | console.log(_.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }))); 14 | // => [{ 'a': 1, 'b': 2 }] -------------------------------------------------------------------------------- /02-Lodash/examples/util/05_constant.js: -------------------------------------------------------------------------------- 1 | /** 2 | * constant example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var objects = _.times(2, _.constant({ 'a': 1 })); 9 | 10 | console.log(objects); 11 | // => [{ 'a': 1 }, { 'a': 1 }] 12 | 13 | console.log(objects[0] === objects[1]); 14 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/util/06_defaultto.js: -------------------------------------------------------------------------------- 1 | /** 2 | * defaultTo example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.defaultTo(1, 10)); 9 | // => 1 10 | 11 | console.log(_.defaultTo(undefined, 10)); 12 | // => 10 -------------------------------------------------------------------------------- /02-Lodash/examples/util/07_flow.js: -------------------------------------------------------------------------------- 1 | /** 2 | * flow example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function square(n) { 9 | return n * n; 10 | } 11 | 12 | var addSquare = _.flow([_.add, square]); 13 | console.log(addSquare(1, 2)); 14 | // => 9 -------------------------------------------------------------------------------- /02-Lodash/examples/util/08_flowright.js: -------------------------------------------------------------------------------- 1 | /** 2 | * flowRight example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | function square(n) { 9 | return n * n; 10 | } 11 | 12 | var addSquare = _.flowRight([square, _.add]); 13 | console.log(addSquare(1, 2)); 14 | // => 9 -------------------------------------------------------------------------------- /02-Lodash/examples/util/09_identity.js: -------------------------------------------------------------------------------- 1 | /** 2 | * identity example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var object = { 'a': 1 }; 9 | 10 | console.log(_.identity(object) === object); 11 | // => true -------------------------------------------------------------------------------- /02-Lodash/examples/util/10_iteratee.js: -------------------------------------------------------------------------------- 1 | /** 2 | * iteratee example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var users = [ 9 | { 'user': 'barney', 'age': 36, 'active': true }, 10 | { 'user': 'fred', 'age': 40, 'active': false } 11 | ]; 12 | 13 | // The `_.matches` iteratee shorthand. 14 | console.log(_.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 15 | // => [{ 'user': 'barney', 'age': 36, 'active': true }] 16 | 17 | // The `_.matchesProperty` iteratee shorthand. 18 | console.log(_.filter(users, _.iteratee(['user', 'fred'])); 19 | // => [{ 'user': 'fred', 'age': 40 }] 20 | 21 | // The `_.property` iteratee shorthand. 22 | console.log(_.map(users, _.iteratee('user')); 23 | // => ['barney', 'fred'] 24 | 25 | // Create custom iteratee shorthands. 26 | console.log(_.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 27 | return !_.isRegExp(func) ? iteratee(func) : function(string) { 28 | return func.test(string); 29 | }; 30 | })); 31 | 32 | console.log(_.filter(['abc', 'def'], /ef/)); 33 | // => ['def'] -------------------------------------------------------------------------------- /02-Lodash/examples/util/11_matches.js: -------------------------------------------------------------------------------- 1 | /** 2 | * matches example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var objects = [ 9 | { 'a': 1, 'b': 2, 'c': 3 }, 10 | { 'a': 4, 'b': 5, 'c': 6 } 11 | ]; 12 | 13 | console.log(_.filter(objects, _.matches({ 'a': 4, 'c': 6 }))); 14 | // => [{ 'a': 4, 'b': 5, 'c': 6 }] -------------------------------------------------------------------------------- /02-Lodash/examples/util/12_matchesproperty.js: -------------------------------------------------------------------------------- 1 | /** 2 | * matchesProperty example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var objects = [ 9 | { 'a': 1, 'b': 2, 'c': 3 }, 10 | { 'a': 4, 'b': 5, 'c': 6 } 11 | ]; 12 | 13 | console.log(_.find(objects, _.matchesProperty('a', 4))); 14 | // => { 'a': 4, 'b': 5, 'c': 6 } -------------------------------------------------------------------------------- /02-Lodash/examples/util/13_method.js: -------------------------------------------------------------------------------- 1 | /** 2 | * method example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var objects = [ 9 | { 'a': { 'b': _.constant(2) } }, 10 | { 'a': { 'b': _.constant(1) } } 11 | ]; 12 | 13 | console.log(_.map(objects, _.method('a.b'))); 14 | // => [2, 1] 15 | 16 | console.log(_.map(objects, _.method(['a', 'b']))); 17 | // => [2, 1] -------------------------------------------------------------------------------- /02-Lodash/examples/util/14_methodof.js: -------------------------------------------------------------------------------- 1 | /** 2 | * methodOf example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var array = _.times(3, _.constant), 9 | object = { 'a': array, 'b': array, 'c': array }; 10 | 11 | console.log(_.map(['a[2]', 'c[0]'], _.methodOf(object))); 12 | // => [2, 0] 13 | 14 | console.log(_.map([['a', '2'], ['c', '0']], _.methodOf(object))); 15 | // => [2, 0] -------------------------------------------------------------------------------- /02-Lodash/examples/util/15_mixin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * mixin example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | 9 | function vowels(string) { 10 | return _.filter(string, function(v) { 11 | return /[aeiou]/i.test(v); 12 | }); 13 | } 14 | 15 | _.mixin({ 'vowels': vowels }); 16 | console.log(_.vowels('fred')); 17 | // => ['e'] 18 | 19 | _('fred').vowels().value(); 20 | // => ['e'] 21 | 22 | _.mixin({ 'vowels': vowels }, { 'chain': false }); 23 | console.log(_('fred').vowels()); 24 | // => ['e'] -------------------------------------------------------------------------------- /02-Lodash/examples/util/16_noconflict.js: -------------------------------------------------------------------------------- 1 | /** 2 | * noConflict example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var lodash = _.noConflict(); 9 | console.log(lodash); -------------------------------------------------------------------------------- /02-Lodash/examples/util/17_noop.js: -------------------------------------------------------------------------------- 1 | /** 2 | * noop example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.times(2, _.noop)); 9 | // => [undefined, undefined] -------------------------------------------------------------------------------- /02-Lodash/examples/util/18_ntharg.js: -------------------------------------------------------------------------------- 1 | /** 2 | * nthArg example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var func = _.nthArg(1); 9 | console.log(func('a', 'b', 'c', 'd')); 10 | // => 'b' 11 | 12 | var func = _.nthArg(-2); 13 | console.log(func('a', 'b', 'c', 'd')); 14 | // => 'c' -------------------------------------------------------------------------------- /02-Lodash/examples/util/19_over.js: -------------------------------------------------------------------------------- 1 | /** 2 | * over example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var func = _.over([Math.max, Math.min]); 9 | 10 | console.log(func(1, 2, 3, 4)); 11 | // => [4, 1] 12 | -------------------------------------------------------------------------------- /02-Lodash/examples/util/20_overevery.js: -------------------------------------------------------------------------------- 1 | /** 2 | * func example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var func = _.overEvery([Boolean, isFinite]); 9 | 10 | console.log(func('1')); 11 | // => true 12 | 13 | console.log(func(null)); 14 | // => false 15 | 16 | console.log(func(NaN)); 17 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/util/21_oversome.js: -------------------------------------------------------------------------------- 1 | /** 2 | * overSome example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var func = _.overSome([Boolean, isFinite]); 9 | 10 | console.log(func('1')); 11 | // => true 12 | 13 | console.log(func(null)); 14 | // => true 15 | 16 | console.log(func(NaN)); 17 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/util/22_property.js: -------------------------------------------------------------------------------- 1 | /** 2 | * property example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | 9 | var objects = [ 10 | { 'a': { 'b': 2 } }, 11 | { 'a': { 'b': 1 } } 12 | ]; 13 | 14 | console.log(_.map(objects, _.property('a.b'))); 15 | // => [2, 1] 16 | 17 | console.log(_.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b')); 18 | // => [1, 2] -------------------------------------------------------------------------------- /02-Lodash/examples/util/23_propertyof.js: -------------------------------------------------------------------------------- 1 | /** 2 | * propertyOf example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var array = [0, 1, 2], 9 | object = { 'a': array, 'b': array, 'c': array }; 10 | 11 | console.log(_.map(['a[2]', 'c[0]'], _.propertyOf(object))); 12 | // => [2, 0] 13 | 14 | console.log(_.map([['a', '2'], ['c', '0']], _.propertyOf(object))); 15 | // => [2, 0] -------------------------------------------------------------------------------- /02-Lodash/examples/util/24_range.js: -------------------------------------------------------------------------------- 1 | /** 2 | * range example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | 9 | console.log(_.range(4)); 10 | // => [0, 1, 2, 3] 11 | 12 | console.log(_.range(-4)); 13 | // => [0, -1, -2, -3] 14 | 15 | console.log(_.range(1, 5)); 16 | // => [1, 2, 3, 4] 17 | 18 | console.log(_.range(0, 20, 5)); 19 | // => [0, 5, 10, 15] 20 | 21 | console.log(_.range(0, -4, -1)); 22 | // => [0, -1, -2, -3] 23 | 24 | console.log(_.range(1, 4, 0)); 25 | // => [1, 1, 1] 26 | 27 | console.log(_.range(0)); 28 | // => [] -------------------------------------------------------------------------------- /02-Lodash/examples/util/25_rangeright.js: -------------------------------------------------------------------------------- 1 | /** 2 | * rangeRight example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | 9 | console.log(_.rangeRight(4)); 10 | // => [3, 2, 1, 0] 11 | 12 | console.log(_.rangeRight(-4)); 13 | // => [-3, -2, -1, 0] 14 | 15 | console.log(_.rangeRight(1, 5)); 16 | // => [4, 3, 2, 1] 17 | 18 | console.log(_.rangeRight(0, 20, 5)); 19 | // => [15, 10, 5, 0] 20 | 21 | console.log(_.rangeRight(0, -4, -1)); 22 | // => [-3, -2, -1, 0] 23 | 24 | console.log(_.rangeRight(1, 4, 0)); 25 | // => [1, 1, 1] 26 | 27 | console.log(_.rangeRight(0)); 28 | // => [] -------------------------------------------------------------------------------- /02-Lodash/examples/util/26_runincontext.js: -------------------------------------------------------------------------------- 1 | /** 2 | * runInContext example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | _.mixin({ 'foo': _.constant('foo') }); 9 | 10 | var lodash = _.runInContext(); 11 | lodash.mixin({ 'bar': lodash.constant('bar') }); 12 | 13 | console.log(_.isFunction(_.foo)); 14 | // => true 15 | console.log(_.isFunction(_.bar)); 16 | // => false 17 | 18 | console.log(lodash.isFunction(lodash.foo)); 19 | // => false 20 | console.log(lodash.isFunction(lodash.bar)); 21 | // => true 22 | 23 | // Create a suped-up `defer` in Node.js. 24 | var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; -------------------------------------------------------------------------------- /02-Lodash/examples/util/27_stubarray.js: -------------------------------------------------------------------------------- 1 | /** 2 | * stubArray example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var arrays = _.times(2, _.stubArray); 9 | 10 | console.log(arrays); 11 | // => [[], []] 12 | 13 | console.log(arrays[0] === arrays[1]); 14 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/util/28_stubfalse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * stubFalse example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.times(2, _.stubFalse)); 9 | // => [false, false] -------------------------------------------------------------------------------- /02-Lodash/examples/util/29_stubobject.js: -------------------------------------------------------------------------------- 1 | /** 2 | * stubObject example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | var objects = _.times(2, _.stubObject); 9 | 10 | console.log(objects); 11 | // => [{}, {}] 12 | 13 | console.log(objects[0] === objects[1]); 14 | // => false -------------------------------------------------------------------------------- /02-Lodash/examples/util/30_stubstring.js: -------------------------------------------------------------------------------- 1 | /** 2 | * stubString example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.times(2, _.stubString)); 9 | // => ['', ''] -------------------------------------------------------------------------------- /02-Lodash/examples/util/31_stubtrue.js: -------------------------------------------------------------------------------- 1 | /** 2 | * stubTrue example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.times(2, _.stubTrue)); 9 | // => [true, true] -------------------------------------------------------------------------------- /02-Lodash/examples/util/32_times.js: -------------------------------------------------------------------------------- 1 | /** 2 | * times example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.times(3, String)); 9 | // => ['0', '1', '2'] 10 | 11 | console.log(_.times(4, _.constant(0))); 12 | // => [0, 0, 0, 0] -------------------------------------------------------------------------------- /02-Lodash/examples/util/33_topath.js: -------------------------------------------------------------------------------- 1 | /** 2 | * toPath example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.toPath('a.b.c')); 9 | // => ['a', 'b', 'c'] 10 | 11 | console.log(_.toPath('a[0].b.c')); 12 | // => ['a', '0', 'b', 'c'] -------------------------------------------------------------------------------- /02-Lodash/examples/util/34_uniqueid.js: -------------------------------------------------------------------------------- 1 | /** 2 | * uniqueId example 3 | */ 4 | 5 | 'use strict'; 6 | var _ = require('../../node_modules/lodash'); 7 | 8 | console.log(_.uniqueId('contact_')); 9 | // => 'contact_104' 10 | 11 | console.log(_.uniqueId()); 12 | // => '105' -------------------------------------------------------------------------------- /02-Lodash/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "01-Inquirerjs", 3 | "version": "0.0.1", 4 | "devDependencies": { 5 | "jquery": "^3.2.1", 6 | "lodash": "^4.17.4" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /03-Webpack/01-basic/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /dist 3 | -------------------------------------------------------------------------------- /03-Webpack/01-basic/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Sudheer Jonna 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /03-Webpack/01-basic/README.md: -------------------------------------------------------------------------------- 1 | #Basic -------------------------------------------------------------------------------- /03-Webpack/01-basic/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |