Skip to content

Instantly share code, notes, and snippets.

View luckio41's full-sized avatar

Esteban Muñoz Lagos luckio41

View GitHub Profile
@luckio41
luckio41 / shuffle.ts
Created December 14, 2017 14:30
Typescript shuffle function
/**
* Shuffle
* @param a
*/
shuffle(a) {
for (let i = a.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
return a;
@luckio41
luckio41 / format.pipe.ts
Created December 14, 2017 19:14
Number Format Pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'numberFormat'
})
export class FormatPipe implements PipeTransform {
transform(value: any, ...args: any[]): any {
value = value.toString().split('').reverse().join('').replace(/(?=\d*\.?)(\d{3})/g, '$1.');
value = value.split('').reverse().join('').replace(/^[\.]/, '');