0.1.1 • Published 8 years ago

module-data v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

module-data

This module gathers a module's statistical data. There are three statistical data types and those are local data, remote data and standard data, being the last one a merge between the first two.

You can see here the data structure of those three statistical data types.

Installation

$ npm i module-data

Documentation

Core

Toolbox

Core

local(modulePath, options, callback)

This method will traverse local module data and return a tree based on this schema.

var localData = require('module-data').local

var options = {
  depth: 10
}

localData(process.cwd(), options, function (err, data) {
  ...
})

remote(moduleName, options, callback)

This method will query remotely the module data and return a flat object based on this schema.

var remoteData = require('module-data').remote

var options = {
  version: '1.0.0'
}

remoteData('module-data', options, function (err, data) {
  ...
})

Toolbox

dependenciesSet(data)

This method will return a dependencies' Set object from the local data tree.

var getDepsTree = require('module-data/dependencies-set')

var localData = { ... }

// {
//    'async': ['1.0.0', '1.1.2'],
//    'request': ['0.1.0']
// }
var depsTree = getDepsTree(localData)

standardize(data, callback)

This method will merge local data and remote data into a standard data.

var standardize = require('module-data/standardize')

var data = {
  local: { ... },
  remote: { ... }
}

standardize(data, function (err, standardData) {
  ...
})

validate(type, data, callback)

This method validates local data, remote data and standard data.

var validate = require('module-data/validate')

var localData = { ... }
var remoteData = { ... }
var standardData = { ... }

function handleValidation (err) {
  ...
}

validate('local', localData, handleValidation)
validate('remote', remoteData, handleValidation)
validate('standard', standardData, handleValidation)