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

shakespeare-data

v3.0.0

Published

A little JavaScript library you can import and use in your projects as an alternative to Lorem Ipsum style test data.

Downloads

385

Readme

shakespeare-data

A little JavaScript library you can import and use in your projects as an alternative to Lorem Ipsum style test data.

travis build version

Installation

npm i --save shakespeare-data

API

All of Shakespeare's sonnets are included, with a simple API to retrieve them:

sonnets.all()

Retrieves all the sonnets in an array in the following structure:

[{"number": 1,
  "lines":
   [ "Those lips that Love's own hand did make,",
     "Breathed forth the sound that said 'I hate',",
     "To me that languish'd for her sake:",
     "But when she saw my woeful state,",
     "Straight in her heart did mercy come,",
     "Chiding that tongue that ever sweet",
     "Was us'd in giving gentle doom;",
     "And taught it thus anew to greet;",
     "'I hate' she alter'd with an end,",
     "That followed it as gentle day,",
     "Doth follow night, who like a fiend",
     "From heaven to hell is flown away.",
     "'I hate', from hate away she threw,",
     "And sav'd my life, saying 'not you'." 
     ] 
},...
]

sonnets.find(term)

Retrieves all the sonnets matching the term in an array in the same structure as all():

sonnets.random()

Retrieves a single sonnet randomly from the list of all sonnets.

Use it in Node!

If you're on a node server, just require it and off you go.

var shakespeare = require('shakespeare-data');
var sonnetsContainingTruth = shakespeare.sonnets.find('truth');

Use it in Angular

Import it in angular by importing it into a component and binding it with an HTML template.

Example: https://luketn.github.io/shakespeare-data/

Code: https://github.com/luketn/shakespeare-data/blob/master/example-angular/src/app/app.component.ts

Component:

import { Component } from '@angular/core';
import { Shakespeare } from 'shakespeare-data/lib/shakespeare';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  shakespeare = new Shakespeare();

  sonnets = this.shakespeare.sonnets.all();
  search(term) {
    this.sonnets = this.shakespeare.sonnets.find(term);
  }
}

Template:

<tbody>
  <tr *ngFor="let sonnet of sonnets">
    <td>{{sonnet.number}}</td>
    <td>
      <span *ngFor="let line of sonnet.lines">
        {{line}}<br/>
      </span>
    </td>
  </tr>
</tbody>

Contributions

If you'd like to contribute to the project, note that we use semantic versioning and commitizen conventions.

These differentiate breaking and non-breaking changes clear, and update version numbers for changes accordingly.

Commitizen: http://commitizen.github.io/cz-cli/

Semantic Release: https://semantic-release.gitbooks.io/semantic-release

Use the package script 'commit' to perform commits, which will invoke commitizen correctly:

git add .
npm run commit