digitalbazaar/bedrock-angular-filters

Name: bedrock-angular-filters

Owner: Digital Bazaar, Inc.

Description: Bedrock AngularJS Filters

Created: 2015-01-20 23:20:06.0

Updated: 2017-09-09 01:37:47.0

Pushed: 2017-05-30 16:23:47.0

Homepage: null

Size: 29

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

bedrock-angular-filters

A bedrock bower module that implements various AngularJS filters.

Quick Examples
 show a readable byte count -->
>Download size: {{downloadSize | bytes}}</div>

 mask a credit card number -->
>Card number: {{cardNumber | mask}}</div>
Setup
r install bedrock-angular-filters

Installation of the module followed by a restart of your bedrock server is sufficient to make the module and filters available to your application.

To manually add bedrock-angular-filters as a dependency:

lar.module('myapp', ['bedrock.filters']);
Filters
bytes

Humanize a number into a readable quantity of bytes.

MBER | bytes[:PRECISION]}}

Options:

34 | bytes}} => '1.2 KiB'
3456 | bytes}} => '120.6 KiB'
34567890 | bytes}} => '1.1 GiB'
3456789012345 | bytes}} => '112.3 TiB'
3456789012345678 | bytes}} => '109.7 PiB'
3456789012345678 | bytes:3}} => '109.652 PiB'
ceil

Perform a Math.ceil operation on a string number.

RING_NUMBER | ceil[:DIGITS]}}

Options:

.123' | ceil}} => '1.13'
.991' | ceil}} => '1.00'
.991' | ceil:4}} => '0.9910'
ellipsis

Limit the length of a string and show ellipsis if needed.

RING | ellipsis[:LENGTH]}}

Options:

bcdefg' | ellipsis:10}} => 'abcdefg'
bcdefg' | ellipsis:6}} => 'abc...'
bcdefg' | ellipsis:1}} => '...'
embedded-string

Replace carriage return (0x0d) with \r (0x5c 0x72) and newline (0x0a) with \n (0x5c 0x63).

RING | embeddedString}}

lti_line_string | embeddedString}} => 'abc\r\ndef'
encodeuricomponent

Process a string with encodeURIComponent.

RING | encodeuricomponent}}

ttp://foo.bar?baz=fuzz' | encodeuricomponent}} => 'http%3A%2F%2Ffoo.bar%3Fbaz%3Dfuzz'
floor

Perform a Math.floor operation on a string number.

RING_NUMBER | floor[:DIGITS]}}

Options:

.123' | floor}} => '1.12'
.991' | floor:3}} => '0.991'
.991' | floor:4}} => '0.9910'
isEmpty

Check if a string, array, or object is empty.

LUE | isEmpty}}

 | isEmpty}} => true
234' | isEmpty}} => false
 | isEmpty}} => true
234] | isEmpty}} => false
 | isEmpty}} => true
value': 1234} | isEmpty}} => false
mask

Show only the 4 final characters of a string and mask the rest.

RING | mask[:LENGTH]}}

Options:

2345' | mask}} => '*2345'
2345' | mask:4}} => '2345'
2345' | mask:8}} => '****2345'
now

Filter the current date and time through the date filter.

 | now:FORMAT}}

Options:

 | now:'d MMM yyyy'}} => '1 Jan 2001'
prefill

Fill the beginning of a string with a character.

RING | prefill[:LENGTH][:CH]}}

Options:

' | prefill}} => '01'
' | prefill:2:'a'}} => 'a1'
' | prefill:3}} => '001'

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.