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

vue-computed-helpers

v1.3.0

Published

Computed helpers for Vue apps

Downloads

259

Readme

vue-computed-helpers

NPM version Build Status

This package contains bunch of useful helpers that can be used to simplify computed properties

:cd: Installation

Via npm:

npm install vue-computed-helpers --save

Via yarn:

yarn add vue-computed-helpers

:rocket: Usage

import { eq, count, countBy } from 'vue-computed-helpers'

export default {
  data() {
    return {
      todos: [
        { title: 'Clean house', done: false },
        { title: 'Buy beer', done: true },
        { title: 'Watch GoT', done: true }
      ]
    }
  },
  computed: {
    allTodosCount: count('todos'), // 3
    completedCount: countBy('todos', 'done', true), // 2
    allCompleted: eq('completedCount', 'allTodosCount') // false
  }
}

:star: Helpers

| Helper | Usage | Variable argument count allowed | |:-------|:------|:--------------------------------| | eq | eq('anyProperty', x) | no | | notEq | notEq('anyProperty', x) | no| | not | not('anyProperty', 'anotherProp', ...) | yes | | and | and('anyProperty', 'anotherProp', ...) | yes | | or | or('anyProperty', 'anotherProp', ...) | yes | | xor | xor('anyProperty', 'anotherProp') | no | | gt | gt('numProperty', x) | no | | gte | gte('numProperty', x) | no | | lt | lt('numProperty', x) | no | | lte | lte('numProperty', x) | no | | sum | sum('numProperty', x, ...) | yes | | alias | alias('anyProperty') | no | | bool | bool('anyProperty') | no | | empty | empty('anyProperty') | no | | min | min('arrayProperty') | no | | max | max('arrayProperty') | no | | filter | filter('arrayProperty', (el) => el.done === true) | no | | filterBy | filterBy('arrayProperty', 'done', true) | no | | find | find('arrayProperty', (el) => el.id === 5) | no | | findBy | findBy('arrayProperty', 'id', 5) | no | | map | map('arrayProperty', (el) => el.id) | no | | mapBy | mapBy('arrayProperty', 'id') | no | | count | count('arrayProperty') | no | | countBy | countBy('arrayProperty', 'done', true) | no | | classObject | classObject('isPrimary', 'has-title:title', 'wide') | yes |

x means that it can be either value or property name. If you provide a string and there will be a property with that name it's value will be used to perform the check.

:mag: Detailed usage of some helpers

classObject

Example code:

import { classObject } from 'vue-computed-helpers'

export default {
  props: ['isPrimary', 'title', 'wide']
  computed: {
    classObj: classObject('isPrimary', 'has-title:title', 'wide')
  }
}

Given all above props are set and truthy, this computed property will return the following object:

{
  'is-primary': true,
  'has-title': true,
  'wide': true
}

Which can be used in template:

<template>
  <div :class="classObj">
  </div>
</template>

:lock: License

See the LICENSE file for license rights and limitations (MIT).