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

doi2bib

v1.0.10

Published

A node.js package to retrieve citation information of any given DOI, document or string text, and update it to a specified BibText (.bib) file.

Downloads

21

Readme

Status GitHub Issues GitHub Pull Requests NPM Downloads License


📝 Table of Contents

🧐 About

This package parse Markdown files or text strings searching for DOI references with the format: @DOI:---.---/-----------. It keeps a *.bib file (library.bib per default) updated by adding the necessary references and information obtained from http://dx.doi.org/.

This package is used as part of the pandoc-doi2bib filter and pdf2doi utilities.

🏁 Getting Started

These instructions will get you the doi2bib package to use on your node projects.

Installing

For using as Node.js package use:

npm install --save doi2bib

And for development, clone the repository as:

git clone https://github.com/aeroreyna/doi2bib
cd doi2bib
npm install

🎈 Usage

This package exposes the following functions:

  • updateFromText(text): Looks for DOI references and updates the .bib file.
  • updateFromFile(file): Read the file and uses the function updateFromText.
  • watchFile(file): Read the file and keeps and eye on it looking for new references.
  • getCitation(DOI): Obtain and return the citation of the DOI document and added to the library if necessary.
  • setLibraryFile(file): Change the bibliography .bib file to work on.

An example could be:

const doi2bib = require("./index.js");

doi2bib.getCitation('10.1007/s10462-018-09676-2').then((r)=>{
  console.log(r)
});

Which keeps an eye on the specified file in case of new DOI references are given.

Using Gulp

It also can be used with Gulp as a task to act when .md files in a directory changes using the follow gulp file.

const { src, dest, watch, task } = require('gulp');
const through = require('through2');
const doi2bib = require('doi2bib');


let updateBib = function() {
  return src(['**/*.md','!./node_modules/**/*.md'])
    .pipe(through.obj(function (chunk, enc, cb) {
      console.log('File:', chunk.path);
      doi2bib.updateFromText(chunk.contents.toString());
      cb(null, chunk);
    }));
}

task('default', updateBib);

let watcher = watch(['**/*.md','!./node_modules/**/*.md']);

watcher.on('change', function(path, stats) {
  console.log(`File ${path} was changed`);
  doi2bib.updateBibFromFile(path);
});

watcher.on('add', function(path, stats) {
  console.log(`File ${path} was added`);
  doi2bib.updateBibFromFile(path);
});

⛏️ Built Using

✍️ Authors

See also the list of contributors who participated in this project.

To do:

  • [ ] remove nets dependency
  • [ ] make sure all functions return a Promise
  • [x] catch errors in promises