Coder Social home page Coder Social logo

knicklabs / lorem-ipsum.js Goto Github PK

View Code? Open in Web Editor NEW
282.0 282.0 44.0 1.66 MB

Generate lorem ipsum placeholder text

Home Page: https://www.npmjs.com/package/lorem-ipsum

License: ISC License

TypeScript 100.00%
javascript lorem-ipsum lorem-ipsum-generator nodejs react-native text typescript

lorem-ipsum.js's Introduction

👋 Hi there

I'm Nickolas. I enjoy collaborating with others to make dependable software and delightful products.

🔭 I'm currently working on...

I am a Technical Lead and Staff Software Engineer on the Growth Team at Help Scout.

🌱 I’m currently learning...

I am an incoming student in the Master of Science in Computer Science program at Georgia Tech. My interests are in human-computer interaction and artificial intelligence.

👯 I’m looking to collaborate on...

I am happy to talk with anyone looking to make a career for themself in tech, especially if coming from a non-CS background. I myself started working in software development without a formal CS education.

I am interested in research in AI-human interaction, user interfaces, and accessible technology.

🤔 I’m looking for help with...

I want to create inclusive products and experiences. If you have knowledge, experience, advice, or resources on accessibility and universal design, please share (or say hi)!

💬 Ask me about...

  • Web and mobile app development
  • Accessibility and universal design
  • Remote work
  • Software engineering and career development
  • Software development as a second career
  • Succeeding as a mature student

📫 How to reach me...

You can email me at nickolas [at] knicklabs [dot] com. If you know me, you can also call me, send me a text, or chat with me on Slack. My working hours are 8AM-4PM ET Monday-Friday.

😄 Pronouns...

He/him

⚡ Fun fact...

I have a lot of President's Choice Buffalo Wing Sauce in my kitchen cupboards.

lorem-ipsum.js's People

Contributors

amilajack avatar bbenoist avatar beenotung avatar dependabot[bot] avatar dubzzz avatar jaredly avatar knicklabs avatar lil5 avatar marcobiedermann avatar mklarsen avatar rart avatar sneakertack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lorem-ipsum.js's Issues

Option --copy doesnt copy to clipboard

Hi there!
When writing ie
lorem-ipsum 1 sentence --copy, the clipboard remains with the previous content, not the generated sentence.

I'm on Ubuntu 16.04

Non-random generations

I tried to use this library to generate random text on our UI tests. We take screenshots of the results on our automated UI tests and compare them with baselines. So we need to have always the same text for given parameters. Is this somehow possible with this library?

I tried to play with random parameter but I think it's used to decide per word, so I get the same word repeatedly if I set random: () => 0.5

Circular dependency detected sees cyclic dependency in util/makeArrayOfStrings.js and util/index.js

I use CircularDependencyPlugin to find cyclic modules in my projects, and when using the lorem-ipsum webpack plugin sees the following cyclic dependency:

WARNING in Circular dependency detected:
node_modules/lorem-ipsum/dist/util/index.js -> node_modules/lorem-ipsum/dist/util/makeArrayOfStrings.js -> node_modules/lorem-ipsum/dist/util/index.js

WARNING in Circular dependency detected:
node_modules/lorem-ipsum/dist/util/makeArrayOfStrings.js -> node_modules/lorem-ipsum/dist/util/index.js -> node_modules/lorem-ipsum/dist/util/makeArrayOfStrings.js

To Reproduce
Steps to reproduce the behavior:

  1. Install circular-dependency-plugin:^5.2.2
  2. Install lorem-ipsum:^2.0.4
  3. Use lorem-ipsum class or function
  4. See warning

Expected behavior
It seems to me that there should be no cyclic modules, but I do not know how critical it is in this case and whether I should ignore this warning.

Screenshots
https://i.imgur.com/greWD4u.png

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • webpack: webpack:^5.72.1
  • webpack-cli: webpack-cli:^4.9.2
  • lorem-ipsum: lorem-ipsum:^2.0.4
  • CircularDependencyPlugin: circular-dependency-plugin:^5.2.2

Smartphone (please complete the following information):
none

Additional context
none

Keeps re-rendering the component on tab swop or right click

It would seem that the package seems to re-render the component on tab switch or right-click, so when trying to inspect the code to debug it keeps refreshing.

To Reproduce
Steps to reproduce the behavior:

  1. Install the latest package on Create-React-App
  2. have it used on a component that is using lodash map and renders inside the map
  3. Start app Go to browser and right click and notice each paragraph refresh
  4. See error

Expected behavior
Honestly expected it to just load dummy text once-off for each iteration in the array. I even created an IpsumGen component and used memo on it and it still re-renders.

Code
`import { memo } from 'react';
import { LoremIpsum } from 'lorem-ipsum';

const lorem = new LoremIpsum({
sentencesPerParagraph: {
max: 4,
min: 1,
},
wordsPerSentence: {
max: 16,
min: 4,
},
});

const IpsumGen = () => (
<>
Generate LoremIpsum if Description is NULL - {lorem.generateParagraphs(1)}
</>
);

export default memo(IpsumGen);`

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Browser chrome
  • Version 96.0.4664.110

Additional context
As mentioned, I am using CRA

Capital letters

It would be nice to have (the option of) capital letters in the output in “expected” places.

I propose a new “sentenceCase” option, which when true has the effect of turning the first letter of each sentence to upper-case in paragraph mode (the first letter in the output for other cases).

It might also be nice to have a “properNameFraction” option (perhaps with upper/lower bounds like the others) that randomly capitalizes words (regardless of them actua being proper names), just to mimic the way normal text might look.

Property 'platform' does not exist on type 'Process'

Describe the bug
It is great that the project is fully TypeScript. The only problem is when you use globals like process. That can backfire on you. My projects use strict: true and won't build because of this type error. I have had to resort to a @ts-ignore.

ERROR in /Users/joe/workspace/site_ui_components_v2/node_modules/lorem-ipsum/src/util/isWindows.ts(7,52):
7:52 Property 'platform' does not exist on type 'Process'.
     5 |  */
     6 | const isWindows = (): boolean => {
  >  7 |   return typeof process !== "undefined" && process.platform === SUPPORTED_PLATFORMS.WIN32;
       |                                                    ^
     8 | };
     9 | 
    10 | export default isWindows;
Version: typescript 3.9.7

To Reproduce
Steps to reproduce the behavior:
This error occurs with npm run serve or npm run start (dev server) and with npm run build

Expected behavior
No type errors.

Screenshots
Screenshot 2020-09-04 at 10 20 46

Desktop (please complete the following information):

  • OS: macOS Catalina 10.15.6 & Ubuntu 18.04

Error to import lorem-ipsum in typescript

Describe the bug
I get this error when I import the module:

/home/spielrs/Proyectos/quarantine-digest/node_modules/lorem-ipsum/src/index.ts:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { WORDS } from "./constants/words";
                                                                                                    ^

    SyntaxError: Unexpected token {

      1 | import * as moment from "moment";
      2 | import {IFeed} from "./interfaces";
    > 3 | import {LoremIpsum} from "lorem-ipsum/src";
        | ^
      4 | 
      5 | const emails: IFeed[] = [];
      6 | 

To Reproduce
Steps to reproduce the behavior:
import lorem-ipsum with typescript

import {LoremIpsum} from "lorem-ipsum/src";

Expected behavior

  1. I shouldn't add src to the import path to get the types
  2. I shouldn't get the error when I import it

Desktop (please complete the following information):

  • OS: Solus

Empty string is returned for paragraphs when count is set to 0

Describe the bug

Both loremIpsum({count: 0, units: "words"}) and loremIpsum({count: 0, units: "sentences"}) generate words/sentences based on a random number, but loremIpsum({count: 0, units: "paragraphs"}) returns an empty string. Is this working as intended?

Expected behavior
I think all should have the same behavior.

Version
2.0.3

shorter methods name for convenience?

hi, do you think it's a good idea
to add lorem.w(), lorem.s(), lorem.p() in addition to lorem.generateWords() ...
for typing less for advanced user?

thanks

ES6 syntax

Hey Nickolas great library of yours.
I would like to use it in my project in which I use ES6 syntax.
How about giving your code a little ES6 upgrade? Makes the code a bit cleaner in some ways.
Currently most features are supported in Node.js 4+

I would like to use:

  • let and const instead of var
  • template strings to make string concatenation easier to read and write
  • Object.assign to make default options more easy to set up

Optional:

  • use import and export to support official JavaScript modules.

If you like, I could work on that and send you a PR.

Adding RTL mode

Would you accept a PR that allows us to kick the generator into RTL mode and change the default text from English lipsum to arabic or hebrew (see http://generator.lorem-ipsum.info/_arabic).
Currently, we could only do this with a wrapping script, providing a different wordlist, but testing components in RTL is something that would be great if it came OOTB.

Module fails to load in React Native

In React Native 0.56, including lorem-ipsum fails.

This is due to lib/generator.js requiring('os') in the conditional block:-

    if (!isReactNative && isNode) {
      suffix = require('os').EOL
    } else {
      suffix = '\n'
    }

!isReactNative && isNode correctly evaluates to false but React Native is still checking the haste cache for require('os').

screenshot 2018-08-18 09 02 09

Custom (repeatable) number generator

It would be nice to allow using a custom random number generator. There are already such generators written in JS that allow various improvements on Math.random, in particular they can be seeded such that they generate a repeatable sequence.

Since I already had an equivalent I hacked this in by replacing the randomInteger definition in generator.js with:

var randomInteger = options.randomInteger || function(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}

But any drop-in PRNG replacement will probably contain a Math.random()-like function so it might make more sense to use that as an option name.

React Native: Unable to resolve module `child_process`

Hi

I'm trying to install lorem-ipsum in my react-native project, but I'm getting the following error from my bundler:

error: bundling failed: Error: Unable to resolve module child_process from /Users/jenskuhrjorgensen/Documents/Workspace/journl-incontinence/mobile/node_modules/lorem-ipsum/dist/index.js: Module child_process does not exist in the Haste module map

I've tried to restart the metro bundler with npm run start -- --reset-cache and remove and re-install node_modules, but to no avail.

Any help would be appreciated! :)

Environment:
"react": "16.6.3"
"react-native": "0.58.5"
"lorem-ipsum": "2.0.0-alpha.7"

Package size skyrocketed between 1.x and 2.x versions

Both bundlephobia and npm-download-size agree on the fact that the size of the npm package skyrocketed with the current alpha.

According to npm-download-size:

No problem on my side but I think it might be an issue for users serving web-content relying on this library.

An option to set the random seed to get predictable output

Is your feature request related to a problem? Please describe.

I'm using this package in a Nuxt project which does server side rendering (SSR) and then client re-hydration. This means that the lorem ipsum generated on first page load is rendered on the server, displays briefly in the brower, and is then quickly replaced during hydration with a different set of lorem ipsum.

Describe the solution you'd like

I do not want the content to differ between what the server renders and what the client re-renders during hydration. Ideally, I could set a random seed so that the lorem ipsum being generated is always the same.

const lorem = new LoremIpsum({ seed: 123 })
const comment = lorem.generateSentences(2)

Describe alternatives you've considered

Hard coding the lorem ipsum would be the easiest solution. However, we rely on randomly generated content for adding things like fake reviews, fake comments, etc.

Additional context

Add some meta commands to the CLI

It would be nice to have some commands to view the syntax/commands and the version via the CLI.

$ lorem-ipsum -v [--version]
$ lorem-ipsum help [-h [ --help]]

Just a thought as I updated my local package.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.