Socket
Socket
Sign inDemoInstall

barth

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

barth - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

29

index.js
var quotes = require('./data').quotes
function getAQuote () {
var pick = Math.floor(Math.random() * quotes.length)
function getAQuote (idx) {
var pick = idx || Math.floor(Math.random() * quotes.length)
return quotes[pick]
}
module.exports = function(num) {
function formatter (quote, opts) {
if (opts.textOnly) return quote.text
return quote
}
module.exports = exports = function(num, opts) {
if (!opts && typeof num === 'object') {
opts = num
num = 1
}
num = Math.floor(+num || 1)
if (num === 1) return getAQuote()
opts = Object(opts)
if (num === 1) return formatter(getAQuote(), opts)
var quotes = []
for (var i = 1; i <= num; i++) {
quotes.push(getAQuote())
quotes.push(formatter(getAQuote(), opts))
}
return quotes
}
exports.daily = function(opts) {
opts = Object(opts)
var now = new Date()
, beginningOfDay = (new Date(now.getFullYear(), now.getMonth(), now.getDate())) / 1000
return formatter(getAQuote(beginningOfDay % quotes.length), opts)
}

2

package.json
{
"name": "barth",
"version": "1.0.0",
"version": "1.1.0",
"description": "Helpful Karl Barth quotes.",

@@ -5,0 +5,0 @@ "main": "index.js",

# barth
Helpful Karl Barth quotes.
[![NPM](https://nodei.co/npm/barth.png?downloads=true)](https://nodei.co/npm/barth/)
## CLI

@@ -16,5 +18,16 @@ ```

## Usage
```barth([num [, options]])```
```
var barth = require('barth')
barth()
barth() // => {text: 'A quote.'}
barth(3) // => [{text: 'An array of 3 quotes.'},{...},{...}]
barth({textOnly: true}) // => 'Only the quote text will be returned.'
```
```barth.daily([options])```
```
barth.daily() // => '{text: 'A quote that will show all day long.}'
barth.daily({textOnly: true}) // => 'A quote that shows all day long.'
```
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