Coder Social home page Coder Social logo

squarrific / ember-number-to-human-size Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kellysutton/ember-number-to-human-size

0.0 1.0 0.0 1.36 MB

A simple Ember helper for adding a Rails-inspired number-to-human-size helper

License: MIT License

JavaScript 70.88% HTML 29.12%

ember-number-to-human-size's Introduction

ember-number-to-human-size

Build Status npm version Codacy Badge Code Climate Ember Observer Score

An Ember template helper inspired by the Rails number_to_human_size method. It makes displaying file sizes in human-readable fashion easy.

It supports both IEC Byte Units (KiB, MiB, etc.) and traditional byte units (kB, MB, etc.).

Installation

$ ember install ember-number-to-human-size

Usage

Pretty darn simple. There are three parameters, the second and third being optional:

{{number-to-human-size 1000}} {{!-- prints "1 kB" to the template  --}}

If we want to use IEC Byte Units, just set the second parameter to true:

{{number-to-human-size 1024 true}} {{!-- prints "1 kiB" to the template  --}}
{{number-to-human-size 1024 false 3}} {{!-- prints "1.024 kB" to the template  --}}

Finally, the third parameter lets you specific the number of significant digits. It defaults to 0:

{{number-to-human-size 1024 false 0}} {{!-- prints "1 kB" to the template  --}}
{{number-to-human-size 1024 false 1}} {{!-- prints "1.0 kB" to the template  --}}
{{number-to-human-size 1024 false 2}} {{!-- prints "1.02 kB" to the template  --}}
{{number-to-human-size 1024 false 3}} {{!-- prints "1.024 kB" to the template  --}}

Running a Demo App

$ ember server
$ open http://localhost:4200

Running Tests

$ ember test

Building

$ ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.

ember-number-to-human-size's People

Contributors

kellysutton avatar meleyal avatar elwayman02 avatar simontseng avatar ember-tomster avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.