Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More โ†’
Socket
Sign inDemoInstall
Socket

@yuheiy/aozora-lorem

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yuheiy/aozora-lorem

The fake text generator using Aozora Bunko.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Aozora lorem

The fake text generator using Aozora Bunko. This makes better "ใ“ใ“ใซใƒ†ใ‚ญใ‚นใƒˆใŒๅ…ฅใ‚Šใพใ™".

Inspired by faker.js.

Install

npm install @yuheiy/aozora-lorem

Usage

const pug = require('pug')
const { loadBook } = require('@yuheiy/aozora-lorem')

loadBook('https://www.aozora.gr.jp/cards/000081/files/456_15050.html').then(
  ({ lorem }) => {
    const html = pug.render('p= lorem.paragraph()', { lorem })
    // "<p>ใ€ŒใŠใฃใ‹ใ•ใ‚“ใฏใ€ใผใใ‚’ใ‚†ใ‚‹ใ—ใฆไธ‹ใ•ใ‚‹ใ ใ‚ใ†ใ‹ใ€‚ใ€</p>"
  },
)

API

loadBook(url)

Load data from Aozora Bunko and returns an instance of book. Specify the URL of the book's XHTML file as an argument.

You can get the URL from the link to the "XHTMLใƒ•ใ‚กใ‚คใƒซ" on the "ๅ›ณๆ›ธใ‚ซใƒผใƒ‰" page.

const { loadBook } = require('@yuheiy/aozora-lorem')

loadBook('https://www.aozora.gr.jp/cards/000081/files/456_15050.html').then(
  (book) => {
    book.lorem.paragraph()
  },
)

book.lorem.content

An array containig all of the content.

book.content
// [
//   "ไธ€ใ€ๅˆๅŽใฎๆŽˆๆฅญ",
//   "ใ€Œใงใฏใฟใชใ•ใ‚“ใฏใ€ใใ†ใ„ใ†ใตใ†ใซๅทใ ใจไบ‘ใ‚ใ‚ŒใŸใ‚Šใ€ไนณใฎๆตใ‚ŒใŸใ‚ใจใ ใจไบ‘ใ‚ใ‚ŒใŸใ‚Šใ—ใฆใ„ใŸใ“ใฎใผใ‚“ใ‚„ใ‚Šใจ็™ฝใ„ใ‚‚ใฎใŒใปใ‚“ใจใ†ใฏไฝ•ใ‹ใ”ๆ‰ฟ็Ÿฅใงใ™ใ‹ใ€‚ใ€ๅ…ˆ็”Ÿใฏใ€้ป’ๆฟใซๅŠใ—ใŸๅคงใใช้ป’ใ„ๆ˜Ÿๅบงใฎๅ›ณใฎใ€ไธŠใ‹ใ‚‰ไธ‹ใธ็™ฝใใ‘ใถใฃใŸ้Š€ๆฒณๅธฏใฎใ‚ˆใ†ใชใจใ“ใ‚ใ‚’ๆŒ‡ใ—ใชใŒใ‚‰ใ€ใฟใ‚“ใชใซๅ•ใ‚’ใ‹ใ‘ใพใ—ใŸใ€‚",
//   "ใ‚ซใƒ ใƒ‘ใƒใƒซใƒฉใŒๆ‰‹ใ‚’ใ‚ใ’ใพใ—ใŸใ€‚ใใ‚Œใ‹ใ‚‰ๅ››ไบ”ไบบๆ‰‹ใ‚’ใ‚ใ’ใพใ—ใŸใ€‚ใ‚ธใƒงใƒใƒณใƒ‹ใ‚‚ๆ‰‹ใ‚’ใ‚ใ’ใ‚ˆใ†ใจใ—ใฆใ€ๆ€ฅใ„ใงใใฎใพใพใ‚„ใ‚ใพใ—ใŸใ€‚ใŸใ—ใ‹ใซใ‚ใ‚ŒใŒใฟใ‚“ใชๆ˜Ÿใ ใจใ€ใ„ใคใ‹้›‘่ชŒใง่ชญใ‚“ใ ใฎใงใ—ใŸใŒใ€ใ“ใฎใ”ใ‚ใฏใ‚ธใƒงใƒใƒณใƒ‹ใฏใพใ‚‹ใงๆฏŽๆ—ฅๆ•™ๅฎคใงใ‚‚ใญใ‚€ใใ€ๆœฌใ‚’่ชญใ‚€ใฒใพใ‚‚่ชญใ‚€ๆœฌใ‚‚ใชใ„ใฎใงใ€ใชใ‚“ใ ใ‹ใฉใ‚“ใชใ“ใจใ‚‚ใ‚ˆใใ‚ใ‹ใ‚‰ใชใ„ใจใ„ใ†ๆฐ—ๆŒใกใŒใ™ใ‚‹ใฎใงใ—ใŸใ€‚",
//   ...
// ]

book.lorem.paragraph()

Returens a paragraph at random.

book.lorem.paragraph()
// "ใ€Œใ„ใพ่ชฐใ‚‚ใ„ใชใ„ใงใ‚ใ‹ใ‚Šใพใ›ใ‚“ใ€‚ใ‚ใ—ใŸใซใ—ใฆไธ‹ใ•ใ„ใ€‚ใ€"

book.lorem.paragraphs(lines = random(1, content.length))

Returns paragraphs of the specified number of lines at random. By default the number of lines is random.

book.lorem.paragraphs(3)
// [
//   "ใ‚ธใƒงใƒใƒณใƒ‹ใŒไบ‘ใ„ใพใ—ใŸใ€‚",
//   "ใ€Œ้Š€ๆฒณใ‚นใƒ†ใƒผใ‚ทใƒงใƒณใงใ€ใ‚‚ใ‚‰ใฃใŸใ‚“ใ ใ€‚ๅ›ใ‚‚ใ‚‰ใ‚ใชใ‹ใฃใŸใฎใ€‚ใ€",
//   "ใ€Œใ‚ใ‚ใ€ใผใ้Š€ๆฒณใ‚นใƒ†ใƒผใ‚ทใƒงใƒณใ‚’้€šใฃใŸใ‚ใ†ใ‹ใ€‚ใ„ใพใผใใŸใกใฎๅฑ…ใ‚‹ใจใ“ใ€ใ“ใ“ใ ใ‚ใ†ใ€‚ใ€"
// ]

License

The license for this software is MIT.

Details of the license for Aozora Bunko is here.

FAQs

Package last updated on 14 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc