This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const query = 'old man && scalzi'; | |
| const result = fuseWithOperators(query, mockData); | |
| // → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { HomePage } from '../pages/home/home'; | |
| @NgModule({ | |
| declarations: [ | |
| MyApp, | |
| HomePage | |
| ], | |
| . . . | |
| entryComponents: [ | |
| MyApp, | |
| HomePage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, ViewChild } from '@angular/core'; | |
| import { SomeChildComponent } from './someChild/someChild.component'; | |
| @Component({ | |
| selector: 'app-root', | |
| templateUrl: './app.component.html', | |
| styleUrls: ['./app.component.css'] | |
| }) | |
| export class AppComponent { | |
| @ViewChild(SomeChildComponent) someChildComponent; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <some-parent-component> | |
| <button (click)="callChildFunction()" > call child function </button> | |
| <some-child-component></some-child-component> | |
| </some-parent-component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const someDirtyArray = [0, 1, false, 2, '', 3]; | |
| const cleanedArray = _.compact(someDirtyArray); | |
| // cleanedArray => [1, 2, 3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var users = [ | |
| { firstName: "Ldmarz", lastName: "martinez", age: 28, gender: "male" }, | |
| { firstName: "Suli", lastName: "bern", age: 5, gender: "female" }, | |
| { firstName: "Marianis", lastName: "Carrey", age: 54, gender: "female" }, | |
| { firstName: "Jhon", lastName: "carret", age: 40, gender: "male" } | |
| ]; | |
| var femaleUsers = _.filter(users, function(user) { | |
| return user.gender === 'female' | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const someArray = [1, 1, 3] | |
| const cleanArray = _.uniq(someArray); | |
| // cleanArray === [1, 3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var someNiceObject = { hello: { someDeepKey: "hello" } }; | |
| _.set(someNiceObject, "hello.items[0]", "An item"); | |
| // here items was added safely | |
| // someNiceObject === { hello: { someDeepKey: "hello", items: ["An item"] } } | |
| //Here we can access to a not existing key getting a default value instead | |
| var name = _.get(someNiceObject, "someNotExistingKey", "Ldmarz"); | |
| // name => Ldmarz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var users = [ | |
| { firstName: "Ldmarz", lastName: "martinez", age: 28, gender: "male" }, | |
| { firstName: "Suli", lastName: "bern", age: 5, gender: "female" }, | |
| { firstName: "Marianis", lastName: "Carrey", age: 54, gender: "male" }, | |
| { firstName: "Jhon", lastName: "carret", age: 40, gender: "female" } | |
| ]; | |
| var user = _.find(users, { name: "ldmarz", gender: "male" }); | |
| // { firstName: "Ldmarz", lastName: "martinez", age: 28, gender: "male" }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // find elements | |
| let i = 0; | |
| function writeDOM() { | |
| // Imagine some slow/hard function | |
| $("#result").html(i++); | |
| } | |
| const $checkBox = $('#checkbox'); | |
| const throttleWriteDom = _.throttle(writeDOM, 1000); |