Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a plugin system. #92

Merged
merged 5 commits into from
May 7, 2018
Merged

Added a plugin system. #92

merged 5 commits into from
May 7, 2018

Commits on May 2, 2018

  1. Added a plugin system.

    The plugin system allows users to extend dayjs with additional plugins,
    or change existing functionality.
    
    The plugins work by calling the extend method:
    
    dayjs.extend({
      n: "methodName",
      m: function(arguments) {
         //
      }
    })
    
    When overwriting a function, the original function can be referenced from
    inside the plugin using:
    
    this.getOld(pluginName)
    
    For example:
    
    dayjs.extend({
      n: "format",
      m: function(formatStr) {
        let oldFormat = this.getOld("format")
        let oldResults = oldFormat(formatStr)
        ...
    })
    
    This commit also introduces a plugin which extends the format options to include:
    -Q: Quarter of the year
    -k/kk: 1-24 hour time
    -ddd: Date of the month with ordinal (1st-31st)
    -S: Milliseconds
    schiem committed May 2, 2018
    Configuration menu
    Copy the full SHA
    aa0e564 View commit details
    Browse the repository at this point in the history

Commits on May 5, 2018

  1. Updated the plugin to allow immutability and expose Dayjs class to pl…

    …ugin authors.
    
    Plugins now take the Dayjs (or extended subclass) as a parameter and are responsible
    for installing themselves.
    
    The extend function is chainable, for example:
    dayjs.extend(plugin1).extend(plugin2)
    
    The extend function also now takes a second boolean parameter, which will return a new
    version of dayjs. Example:
    
    var extended = dayjs.extend(plugin1, true)
    extended().plugin1()
    dayjs().plugin1() //Error
    schiem committed May 5, 2018
    Configuration menu
    Copy the full SHA
    255e303 View commit details
    Browse the repository at this point in the history
  2. Removed unnecessary function.

    schiem committed May 5, 2018
    Configuration menu
    Copy the full SHA
    f79f1b0 View commit details
    Browse the repository at this point in the history

Commits on May 6, 2018

  1. Configuration menu
    Copy the full SHA
    0fa423f View commit details
    Browse the repository at this point in the history

Commits on May 7, 2018

  1. Configuration menu
    Copy the full SHA
    4f9eb23 View commit details
    Browse the repository at this point in the history