+81
| # reflinks [](https://www.npmjs.com/package/reflinks) [](https://npmjs.org/package/reflinks) [](https://travis-ci.org/jonschlinkert/reflinks) | ||
| Generate (relative) reference links for a glob of markdown files, allowing you to more easily create references from one file to another. | ||
| ## Table of Contents | ||
| ## Install | ||
| Install with [npm](https://www.npmjs.com/): | ||
| ```sh | ||
| $ npm install --save reflinks | ||
| ``` | ||
| **HEADS UP!** | ||
| The API was completely changed in v0.2. The main export is now an async function that expects a callback, and instead of globbing local files, reflinks are created from npm package names. | ||
| ## Usage | ||
| ```js | ||
| var reflinks = require('reflinks'); | ||
| reflinks(['base', 'verb', 'generate'], function(err, links) { | ||
| if (err) throw err; | ||
| console.log(links); | ||
| // results in: | ||
| // [ '[generate]: https://github.com/generate/generate', | ||
| // '[verb]: https://github.com/verbose/verb', | ||
| // '[base]: https://github.com/node-base/base' ] | ||
| }); | ||
| ``` | ||
| By default results are cached for 7 days. See [pkg-cache](https://github.com/jonschlinkert/pkg-cache) for more details and API documentation related to caching packages. | ||
| ## About | ||
| ### Related projects | ||
| * [markdown-utils](https://www.npmjs.com/package/markdown-utils): Micro-utils for creating markdown snippets. | [homepage](https://github.com/jonschlinkert/markdown-utils) | ||
| * [remarkable](https://www.npmjs.com/package/remarkable): Markdown parser, done right. 100% Commonmark support, extensions, syntax plugins, high speed - all in… [more](https://github.com/jonschlinkert/remarkable) | [homepage](https://github.com/jonschlinkert/remarkable) | ||
| ### Contributing | ||
| Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
| ### Building docs | ||
| _(This document was generated by [verb-generate-readme][] (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ | ||
| To generate the readme and API documentation with [verb](https://github.com/verbose/verb): | ||
| ```sh | ||
| $ npm install -g verb verb-generate-readme && verb | ||
| ``` | ||
| ### Running tests | ||
| Install dev dependencies: | ||
| ```sh | ||
| $ npm install -d && npm test | ||
| ``` | ||
| ### Author | ||
| **Jon Schlinkert** | ||
| * [github/jonschlinkert](https://github.com/jonschlinkert) | ||
| * [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
| ### License | ||
| Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
| Released under the [MIT license](https://github.com/jonschlinkert/reflinks/blob/master/LICENSE). | ||
| *** | ||
| _This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on July 13, 2016._ | ||
| [verb-generate-readme]: https://github.com/verbose/verb-generate-readme |
+43
-7
@@ -30,3 +30,6 @@ /*! | ||
| options = options || {}; | ||
| var dates = new utils.Dates('dates/reflinks', options); | ||
| var store = new utils.Store('store/reflinks', options); | ||
| var time = new utils.Time(); | ||
| var log = utils.log; | ||
@@ -36,5 +39,35 @@ var color = options.color || 'green'; | ||
| var stop = options.finished || 'created reference links from npm data'; | ||
| var timespan = options.timespan || '1 week ago'; | ||
| var spinner = ora(start).start(); | ||
| utils.pkgs(names, options, function(err, arr) { | ||
| var pkgs = []; | ||
| utils.each(utils.arrayify(names), function(name, next) { | ||
| if (utils.isCached(dates, name, timespan)) { | ||
| if (store.has(name)) pkgs.push(store.get(name)); | ||
| next(); | ||
| return; | ||
| } | ||
| utils.pkg(name, function(err, pkg) { | ||
| if (err) { | ||
| if (err.message === 'document not found') { | ||
| dates.set(name, {}); | ||
| next(); | ||
| return; | ||
| } | ||
| next(err); | ||
| return; | ||
| } | ||
| dates.set(name, pkg); | ||
| store.set(name, pkg); | ||
| pkgs.push(pkg); | ||
| next(); | ||
| }); | ||
| }, function(err) { | ||
| if (err) { | ||
| cb(err); | ||
| return; | ||
| } | ||
| spinner.color = color; | ||
@@ -46,9 +79,8 @@ spinner.text = stop; | ||
| // let the implementor decide what to do when a package doesn't exist | ||
| cb(err, arr); | ||
| cb(err, pkgs); | ||
| return; | ||
| } | ||
| cb(null, linkify(arr, options)); | ||
| cb(null, linkify(pkgs, options)); | ||
| }); | ||
| } | ||
| }; | ||
@@ -60,2 +92,3 @@ /** | ||
| function linkify(arr, options) { | ||
| var obj = {links: [], cache: {}, pkgs: {}}; | ||
| return utils.arrayify(arr).reduce(function(acc, pkg) { | ||
@@ -70,6 +103,9 @@ if (!pkg.name) return acc; | ||
| if (link) { | ||
| acc.push(link.replace(/#readme$/, '')); | ||
| var res = link.replace(/#readme$/, ''); | ||
| acc.links.push(res); | ||
| acc.cache[pkg.name] = res; | ||
| acc.pkgs[pkg.name] = pkg; | ||
| } | ||
| return acc; | ||
| }, []); | ||
| }, obj); | ||
| } |
+10
-4
| { | ||
| "name": "reflinks", | ||
| "description": "Generate (relative) reference links for a glob of markdown files, allowing you to more easily create references from one file to another.", | ||
| "version": "0.2.7", | ||
| "version": "0.3.0", | ||
| "homepage": "https://github.com/jonschlinkert/reflinks", | ||
@@ -14,2 +14,4 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
| "index.js", | ||
| "LICENSE", | ||
| "README.md", | ||
| "utils.js" | ||
@@ -25,7 +27,10 @@ ], | ||
| "dependencies": { | ||
| "async-each": "^1.0.0", | ||
| "data-store": "^0.16.1", | ||
| "date-store": "^0.1.2", | ||
| "get-pkg": "^0.3.0", | ||
| "lazy-cache": "^2.0.1", | ||
| "log-utils": "^0.1.4", | ||
| "log-utils": "^0.2.1", | ||
| "markdown-reference": "^0.1.0", | ||
| "ora": "^0.2.3", | ||
| "pkg-cache": "^0.1.4", | ||
| "pkg-homepage": "^0.1.1", | ||
@@ -49,3 +54,4 @@ "time-diff": "^0.3.1" | ||
| "reference", | ||
| "reflink" | ||
| "reflink", | ||
| "reflinks" | ||
| ], | ||
@@ -52,0 +58,0 @@ "verb": { |
+8
-1
@@ -7,7 +7,10 @@ 'use strict'; | ||
| require('async-each', 'each'); | ||
| require('time-diff', 'Time'); | ||
| require('log-utils', 'log'); | ||
| require('pkg-cache', 'pkgs'); | ||
| require('get-pkg', 'pkg'); | ||
| require('pkg-homepage', 'homepage'); | ||
| require('markdown-reference', 'reference'); | ||
| require('date-store', 'Dates'); | ||
| require('data-store', 'Store'); | ||
| require = fn; | ||
@@ -19,2 +22,6 @@ | ||
| utils.isCached = function(store, name, timespan) { | ||
| return store.has(name) && store.lastSaved(name).lessThan(timespan); | ||
| }; | ||
| /** | ||
@@ -21,0 +28,0 @@ * Expose utils |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
8957
87.23%5
25%114
52%1
-50%81
Infinity%10
42.86%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated