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

pumlhorse

v2.3.4

Published

Utility for creating readable and reusable scripts

Downloads

22

Readme

Pumlhorse

  • PUML (Promise-driven Utility Modeling Language)
  • Horse (Equus caballus)

Pumlhorse is a utility for creating readable and reusable scripts.

For a complete reference, visit pumlhorse.com

Specification

name: Introduction to Pumlhorse
description: This is a basic script that writes some messages
steps:
  - log: Hello!
  - log: Goodbye!

Parameters

name: Use parameters
description: Pass some parameters to those steps
steps:
  - sayGreeting:
      text: Hello, and welcome to Pumlhorse!
  - sayGoodbye:
      language: French
      text: Au revoir!

Variables

name: Pass variables
description: Set and use variables from your steps
steps:
  - myName = John Smith
  - sayGreeting:
      text: Hello, my name is $myName
name: Assign step results to variables
steps:
  #getMyName is a function that returns a string
  - myName = getMyName 
  - sayGreeting:
      text: Hello, my name is $myName
name: Use complex objects in variables
steps:
  #getMyInfo is a function that returns { name: 'John Smith' }
  - myInfo = getMyInfo
  - sayGreeting:
      text: Hello, my name is $myInfo.name
name: Create complex objects as variables
steps:
  - myInfo = value:
      name: John Smith
      age: 34 
  - sayGreeting:
      text: Hello, my name is $myInfo.name

Inline Javascript

name: Use JavaScript inline
steps:
  - myMixedCase = aBcDeFg
  - myLowerCase = $myMixedCase.toLowerCase()
  #myLowerCase is now 'abcdefg'
name: Declare JavaScript functions inline
functions:
  getMyInfo: return { name: 'John Smith', age: 25 }
  logMyInfo:
    # list parameters first 
    - age
    - name
    # list function body last
    - this.log('My name is ' + name + ' and I am ' + age + ' years old')
steps:
  - myInfo = getMyInfo
  - logMyInfo:
      name: $myInfo.name
      age: $myInfo.age
  # logs "My name is John Smith and I am 25 years old"

Conditionals

name: Simple if/then example
functions:
  getTodaysDate:
    - return new Date().getDay()
steps:
  - dayOfWeek = $getTodaysDate()
  - if:
      value: ${ dayOfWeek == 5 }
      is true:
        - log: Congratulations, today is Friday!
      is false:
        - if:
            value: ${ dayOfWeek == 6 || dayOfWeek == 0}
            is true:
              - log: Congratulations, it's the weekend!
            is false:
              - log: Hang in there, you'll make it to the weekend!

Loops

name: Run some things a few times
steps:
  - loopTimes = 14
  - repeat:
      times: $loopTimes
      steps:
        - log: Starting loop
        # do loop steps
        - log: Ending loop
name: Loop through items in a list
functions:
  getLoopItems: return ["a", "b", "c"]
steps:
  - items = getLoopItems
  - for:
      each: item
      in: $items
      steps:
        - log: Working with the letter $item
        - doLoopTasks: $item
name: Run a loop with varying data
functions:
  doLogin: 
    - username
    - password
    - this.log('Login with ' + username + ':' + password)
steps:
  - scenarios:
      base: # (optional) provides a base set of values for every scenario
        username: jsmith
      cases:
        bad password:
          password: abadpassword
        good password:
          password: aBeTTerPassw0rd!
      steps:
        - doLogin:
            username: $username
            password: $password
          #Performs doLogin for "bad password" and "good password" scenarios

Logging

name: Basic logging functions
steps:
  - log: Here's a simple log message
  - warn: Something might be wrong
  - error: Something is definitely wrong!
name: Pass parameters to logging calls
steps:
  - myFavoriteNumber = 42
  - warn: Every tech thing has to have a $myFavoriteNumber reference

Assertions

name: Use assertions
steps:
  # all of these assertions succeed
  - isTrue: ${5 == 7 - 2}
  - isFalse: ${Math.PI == 3}
  - isNull: $fhqwhgads # Variable doesn't exist
  - isNotNull: 42
  - areEqual: 
      expected: men 
      actual: ${"women".substr(2)}
  - areEqual:
      expected:
        game: horseshoe
      actual:
        game: horseshoe
        another: handgrenades
      partial: true # Only properties in expected value will be checked in actual value
  - areNotEqual:
      expected: free as in beer
      actual: free as in speech
  - isEmpty: ${[]}
  - isNotEmpty: ${[3, 4, 5]}
  - contains: 
      array: 
        - 4
        - 5
        - 6
      value: 6
  - contains:
      array:
        - game: horseshoe
          another: handgrenades
      value:
        game: horseshoe 
      partial: true

HTTP Methods

name: Use HTTP methods
steps:
  - findUserResult = http.get:
      url: http://www.tempuri.org/api/findUser
      data: 
        search: jsmith
        page: 2
  # Issues GET request to http://www.tempuri.org/api/findUser?search=jsmith&page=2
  - log: $findUserResult.json.username
  # Logs 'username' property of the JSON response body (requires the content-type to be application/json or text/json)
  - postResult = http.post:
      url: http://www.tempuri.org/api/createUser
      data: 
        firstName: John
        lastName: Smith
      headers:
        Authorization: bearer   eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOjQyLCJ1c2VybmFtZSI6ImVhc3Rlci5lZ2cifQ.U4nejjGFvXSERKtVWrgXXytXqe9oqdg8ws1AyLCp  4o0
  # Issues POST request to http://www.tempuri.org/api/createUser with a JSON request of { "firstName": "John", "lastName": "Smith" }
  - http.isOk: $postResult
  # Asserts that the response was a 200
  - log: $postResult.body #body contains the string content in the response
  # put, delete, patch, head, and options are also available 

Timers

name: Wait for an amount of time
steps: 
  - wait:
      milliseconds: 23
      seconds: 45
  - log: Well that was kinda long
  # Waits for 45.023 seconds
  - wait:
      minutes: 60
      hours: 3
  # Waits for four hours...use at your own discretion
  - log: Is anyone even here anymore?
name: See how long we waited
functions:
  doLongRunningProcess:
    - return this.wait(2000)
steps:
  - timer1 = startTimer
  - doLongRunningProcess
  - stopTimer: $timer1
  - log: That took $timer1.seconds seconds

Parallel tasks

name: Run multiple steps in parallel
steps:
  - parallel:
      - postUpdateToFacebook: This is my new status!
      - postUpdateToTwitter: This is my new tweet!
      - postUpdateToInstagram: This is a picture of my cat!
functions:
  postUpdateToFacebook:
    - status
    - return this.wait(Math.random() * 1000).then(() => this.log('Updated status to ' + status))
  postUpdateToTwitter:
    - tweet
    - return this.wait(Math.random() * 1000).then(() => this.log('Added new tweet:' + tweet))
  postUpdateToInstagram:
    - caption
    - return this.wait(Math.random() * 1000).then(() => this.log('Added new picture with caption:' + caption))

Helpers

Some miscellaneous helpers

JSON serialization

name: Convert from string to object
functions:
  getObject: return { prop: 43 }
steps:
  - obj = getObject
  - jsonString = toJson: $obj
  - log: $jsonString #logs "{prop:43}"
  - newObj = fromJson: $jsonString 
  - log: $newObj.prop #logs "43"