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

kendo-match-model

v1.1.0

Published

A model for unify format of a kendo match

Downloads

3

Readme

kendo-match-model

Model for unify format of a kendo match

Table of Contents

Model Description

This moudule exporta a set of methods that can be used as factory for a Kendo match model

A kendo match will be represented in this model as:

{
  status: String or null,
  l: MATCHSIDEMODEL,
  r: MATCHSIDEMODEL,
  isCurrent: Boolean
}

| Property | Description | Default | Valid values | | ------------- |:-------------| :-------------:| -----| | status |State of match| null|DRAW, ONE_POINT, EXTRA_TIME| | l |Left side match player| empty MATCHSIDEMODEL |MATCHSIDEMODEL| | r |Right side match player| empty MATCHSIDEMODEL |MATCHSIDEMODEL| | isCurrent |It is current an active match?| false|true,fase|

Where a MATCHSIDEMODEL is like:

{
  name: String,
  points: Array of Strings,
  fault: Boolean
}

| Property | Description | Default | Valid values | | ------------- |:-------------| :-------------:| -----| | name |name for player| ""|any string| | points |Array of Points| [] | array of strings| | fault |playes has a fault?| false|true,fase| So, bringing everything together into an object will be like

{
  status: null,
  l: {
      name: '',
      points: [],
      fault: false
  },
  r: {
      name: '',
      points: [],
      fault: false
  },
  isCurrent: false
}

Install

npm install --save kendo-match-model

Usage

First import the model

import KendoMatchModel from '../kendoMatchModel';

Constants

MAX_MATCH_POINTS

Default max points per side on a match

KendoMatchModel.MAX_MATCH_POINTS

Value:

2

POINT_TYPES

Default valid points strings

KendoMatchModel.POINT_TYPES

Value:

{
  men: 'M',
  kote: 'K',
  do: 'D',
  tsuki: 'M',
  hansoku: 'H',
  hantei: 'Ht',
  chosen: 'Ch',
  empty: ' '
}

MATCH_STATUS

Default valid match status

KendoMatchModel.MATCH_STATUS

Value:

{
  draw: 'DRAW',
  onePoint: 'ONE_POINT',
  extraTime: 'EXTRA_TIME'
}

Methods

newMatch

Create a new match.

KendoMatchModel.newMatch({
  leftName:'John',
  rightName:'Jack'
})

Returns:

{
  status: null,
  l: {
      name: 'John',
      points: [],
      fault: false
  },
  r: {
      name: 'Jack',
      points: [],
      fault: false
  },
  isCurrent: false
}

updateMatch

Update some properties of a match

KendoMatchModel.updateMatch(currentMatch, { isCurrent: true })

addPoint

Add a point to a side

KendoMatchModel.addPoint(currentMatch, 'l', KendoMatchModel.POINT_TYPES.men)

finishMatch

When a match is finished a proper status is set and isCurrent will be false.

KendoMatchModel.finishMatch(currentMatch)

setMatch

Input: Partial MATCHMODEL or null.

KendoMatchModel.setMatch({
  isCurrent:true,
  r: {
      name: 'Jack'
  },
})

Returns:

{
  status: null,
  l: {
      name: '',
      points: [],
      fault: false
  },
  r: {
      name: 'Jack',
      points: [],
      fault: false
  },
  isCurrent: true
}

setMatchSide

Input: Partial MATCHSIDEMODEL or null.

KendoMatchModel.setMatchSide({
  name: 'Jack'
})

Returns:

{
  name: 'Jack',
  points: [],
  fault: false
}

isValidStatus

Check status name validity

KendoMatchModel.isValidStatus('DRAW')//true

isValidPoint

Check point name validity

KendoMatchModel.isValidPoint('M')//true