Skip to content

Instantly share code, notes, and snippets.

View philipszdavido's full-sized avatar

Chidume Nnamdi philipszdavido

View GitHub Profile
#!/usr/bin/env node
import './polyfills'
import * as commander from 'commander'
import * as inquirer from 'inquirer'
import chalk from 'chalk'
import * as actions from './logic';
import { getIdQuestions, questions, updateContactQuestions } from './questions'
commander
.version('1.0.0')
String.prototype.plural = function () {
if (this.lastChar() === 'y') {
if ( (this.charAt(this.length - 2)).isVowel() ) {
// If the y has a vowel before it (i.e. toys), then you just add the s.
return this + 's';
}
else {
// If a this ends in y with a consonant before it (fly), you drop the y and add -ies to make it plural.
return this.slice(0, -1) + 'ies';
}
{
"name": "myapp",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
{
"name": "scotchy-scotch",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
<app-linklist [articles]='article | async | sort'></app-linklist>
//src/app/redux/sort.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
import { Article } from './models/article';
@Pipe({
name: 'sort'
})
export class SortPipe implements PipeTransform {
transform(articles: Article[], args?: any): Article[] {
<app-linklist [articles]='article | async'></app-linklist>
<app-linklist [articles]='article'></app-linklist>
this.article = this.store.select(fromArticle.getArticles)
//src/app/app.component.ts
article: Observable<Article[]>
constructor(private store: Store<fromArticle.State>){
this.article = this.store.select(fromArticle.getArticles).subscribe((v: Array<Article>) => {
this.article = v.sort((a: Article, b: Article) => {
return b.points - a.points
})
})
}