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-crontab

v0.0.4

Published

Periodic processing management system (crontab) running on Vue.js

Downloads

1,795

Readme

VueCrontab

Periodic processing management system (crontab) running on Vue.js

Introduction

VueCrontab is a plug-in for Vue.js that executes functions according to a specified schedule. The schedule consists of hours, minutes, seconds, days of the week, etc. VueCrontab executes the specified function when it matches the date and time. By using this you can easily implement periodic processing to run in the background.

Install

$ npm install vue-crontab

Examples

Usage

Counter updated every second.

import Vue from 'vue'
import VueCrontab from 'vue-crontab'

Vue.use(VueCrontab)

new Vue({
  el: '#app',
  render: h => h(App)
})
<template>
  <div id="app">
    <div>
      <div class="counter">{{ counter }}</div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      counter: 0
    }
  },
  created () {
    let result = this.$crontab.addJob({
      name: 'counter',
      interval: {
        seconds: '/1',
      },
      job: this.countUp
    })
  },
  methods: {
    countUp () {
      this.counter += 1
    }
  }
}
</script>

Reference

VueCrontab

option

| name | type | description | default | | ------------- | ------------- | ------------- | ------------- | | interval | number | The interval to check the interval of the managed job.(milliseconds) | 1000 | | auto_start | Boolean | Setting whether to automatically move cron when one or more jobs are reached. | true |

examples

call setOption before Vue.use() method.

VueCrontab.setOption({
  interval: 100,
  auto_start: false
})

Vue.use(VueCrontab)

methods

| name | argument | description | | ------------- | ------------- | ------------- | | addJob | Array or Object | | | enableJob | string | Enable job with specified name. | | disableJob | string | Disable job with specified name. | | deleteJob | string | Delete job with specified name. | | execJob | string | Manually execute the job with the specified name. | | startCrontab | - | Stop the periodic processing of VueCrontab. | | stopCrontab | - | Start the periodic processing of VueCrontab. | | setOption | Object | change option of VueCrontab. | | getOption | - | get option of VueCrontab. |

Job

option

| name | type | description | | ------------- | ------------- | ------------- | | name (required) | String | job name. | | interval (required) | Array or String or Object | Specify the periodical execution interval of the job. | | job (required) | Array or Function | Specify the function you want to execute when matching the interval. | | sync | number | Whether to synchronize and execute when multiple jobs are registered. 1 = sync, 0 = not sync(default) | | condition | Array or Function | Add a function when you want to additionally specify job execution conditions in addition to interval. The condition must return Boolean type. |

interval

parameters

| name | range | default | | ------------- | ------------- | ------------- | | milliseconds | 0 - 9 | * | | seconds | 0 - 59 | * | | minutes | 0 - 59 | * | | hours | 0 - 23 | * | | day | 1 - 31 | * | | month | 1 - 12 | * | | year | 0 - | * | | week | 0 - 6 (// Sunday is 0, Monday is 1, and so on.)| * |

Available symbols

| name | description | examples | | ------------- | ------------- | ------------- | | * | All ranges | * | | / | Number divided by 0 | /2 = every 2 seconds. /5 = every 5 seconds. | | - | Within the specified numerical range | 0-10 = between 0 and 10 seconds. | | , | Used to connect conditions | 0,1,2 ... 0,10-20,/7 ... |

interval examples

execute every 0.1 seconds

{milliseconds: '/1'}

If you want to process with milliseconds, change setOption as well.

VueCrontab.setOption({
  interval: 100
})

execute every minute.

{minutes: '/1'}

execute 0 minutes from 0 to 9 o'clock on the 1st of every month.

{seconds: '0', minutes:'0', hours: '0-9', day: '1'}

1,3,5,10-15 o'clock Monday

{week: '0', seconds: '0', minutes:'0', hours: '1,3,5,10-15'}

job arguments

| name | type | description | | ------------- | ------------- | ------------- | | exec_date | Date | Match date and time. | | last_run | Date | Last execution date and time. | | counter | number | Number of executions. | | last_result | any | Return value of the previous function. | | type | String | 'cron' = executed by periodic processing. 'manual = manually execution. |

  methods: {
    countUp ({exec_date, last_run, counter, last_result, type}) {
      return "as the next last_result.";
    }
  }

License

MIT