npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng2-pipe

v1.0.9

Published

The rich angular 2 pipes mall. The project use dataset of countries from [countries-data](https://github.com/dormd/countries-data)

Downloads

43

Readme

Ng2Pipe

The rich angular 2 pipes mall. The project use dataset of countries from countries-data

Used by ng2-countries.

The project was generated with angular-cli.

Demo app

You can see how fun to use this npm in our Demo Application.

Table of Contents

  • Demo app
  • Installation
  • Countries Pipes
    • Country Anthem - a2ToAnthem
    • Country name - a2ToCountry
      • Official name
      • Native name - Default
      • Native name - Specific language
    • Country Capital - a2ToCapital
    • Country Continent - a2ToContinent
    • Country Area - a2ToArea
      • Regular number
      • With Comma style pipe
    • Country Population - a2ToPopulation
      • Regular number
      • With Comma style pipe
    • Country Wiki Link - a2ToWikiLink
    • Country alpha 3 (iso_3166_1_alpha3) to alpha 2 - a3ToA2
  • Ganeral Pipes
    • Comma Style - commaStyle
    • Bytes to Mega-bytes - bytesToMBs
      • Regular use
      • With Comma style pipe (1)
      • With Comma style pipe (2)
  • How to use
  • Development server
  • Build
  • Deploying to Github Pages

Installation

npm install ng2-pipe

Countries Pipes

The countries pipes work with iso_3166_1_alpha2 (a2) countries codes.

The examples written for Israel (IL)

Country Anthem - a2ToAnthem

IL | a2ToAnthem

Result: https://commons.wikimedia.org/wiki/File%3AHatikvah instrumental.ogg?embedplayer=yes

Country name - a2ToCountry

Default: common name

IL | a2ToCountry

Result: Israel

Official name

IL | a2ToCountry: [ 'official' ]

Result: State of Israel

Native name - Default

IL | a2ToCountry: [ 'native' ]

Result: ישראל

Native name - Specific language - by ISO 639-3 language code

IL | a2ToCountry: [ 'native', 'ara' ]

Result: إسرائيل

Country Capital - a2ToCapital

IL | a2ToCapital

Result: Jerusalem

Country Continent - a2ToContinent

IL | a2ToContinent

Result: Asia

Country Area - a2ToArea

Regular number

IL | a2ToArea

Result: 20770

With Comma style pipe

IL | a2ToArea | commaStyle

Result: 20,770

Country Population - a2ToPopulation

Regular number

IL | a2ToPopulation

Result: 8597260

With Comma style pipe

IL | a2ToPopulation | commaStyle

Result: 8,597,260

Country Wiki Link - a2ToWikiLink

IL | a2ToWikiLink

Result: https://wikipedia.org/wiki/Israel

Country alpha 3 (iso_3166_1_alpha3) to alpha 2 - a3ToA2

ISR | a3ToA2

Result: IL

General pipes

Comma Style - commaStyle

123456789 | commaStyle

Result: 123,456,789

Bytes to Mega-bytes - bytesToMBs

Regular use

5389564 | bytesToMBs

Result: 5.14

With Comma style pipe (1)

5389564 | bytesToMBs | commaStyle

Result: 5.14

With Comma style pipe (2)

1024000000000 | bytesToMBs | commaStyle

Result: 976,562.50

How to use

Step1: NgModule file

import { NgModule } from '@angular/core';
import { CountriesPipesModule, GeneralPipesModule } from 'ng2-pipe';

@NgModule({
    imports: [
        CountriesPipesModule,
        GeneralPipesModule
    ]
})
export class SharedModule { }

Step2: Component view file

Specific country name: {{ IL | a2ToCountry }}
Country name by parameter: {{ alpha2 | a2ToCountry }}
Country anthem: <a [href]='alpha2 | a2ToWikiLink'></a>
Specific country population: {{ IL | a2ToPopulation | commaStyle }}

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive/pipe/service/class.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the -prod flag for a production build.

Deploying to Github Pages

Run ng github-pages:deploy to deploy to Github Pages.