Giter VIP home page Giter VIP logo

Comments (5)

jeffrey008 avatar jeffrey008 commented on July 18, 2024

Adding mod helper is a good idea, but I am wondering if we should put mod helper into ember-truth-helpers. To me, ember-truth-helpers should only return boolean instead of numbers.
If we can a addon called 'ember-math-helpers' then that would be great. After that we can use something like this : {{if (eq (mod 10 2) 0)}}

from ember-truth-helpers.

AndersDJohnson avatar AndersDJohnson commented on July 18, 2024

@jeffrey008 Yes, this would broaden scope slightly. What about the simple case of (mod i) representing i % 2 === 0 returning just true or false? Or maybe call them (even i) and (odd i)? Still, I can see if you don't want in this module.

from ember-truth-helpers.

jeffrey008 avatar jeffrey008 commented on July 18, 2024

Good idea. Here is my implementation of the helper is-even

export function isEvenHelper(params) {
  if (type of params[0] !== number){
    Ember.assert(`Expected number: get ${typeof params[0]} instead`);
 } 
  return params[0] % 2 === 0;
}

Anyway this is just the first draft of the function, so feel free to modify it.
Also I am wondering if we need a is-odd helper, although we can use the result of is-even to know it is odd or not, there may be a case where the params is not integer.

from ember-truth-helpers.

Turbo87 avatar Turbo87 commented on July 18, 2024

please note that a mod helper is already a part of https://github.com/shipshapecode/ember-math-helpers so there is probably no need to recreate it here too

from ember-truth-helpers.

rwjblue avatar rwjblue commented on July 18, 2024

Makes sense!

from ember-truth-helpers.

Related Issues (20)

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.