Giter VIP home page Giter VIP logo

superspin's Introduction

Introduction

Superspin is a JavaScript library for spinning a text. This is useful for article generator that seed many alternative texts.

Installation

Node:

npm install superspin

Go:

go get -u github.com/raitucarp/superspin

How to use

Node/Javascript:

const Superspin = require('superspin');


const $superspin = new Superspin();

let str = 'Hello there. {You should eat {fruits, veggies and grains|veggies, fruits and grains|fruits, grains and veggies|grains, fruits and veggies|veggies, grains and fruits|grains, veggies and fruits} if you want to be healthy.|If you want to be healthy, you should eat {fruits, veggies and grains|veggies, fruits and grains|fruits, grains and veggies|grains, fruits and veggies|veggies, grains and fruits|grains, veggies and fruits}.}';

let spinText = $superspin.spin(str);
console.log(spinText)

Golang:

import "github.com/raitucarp/superspin"

func main() {
  sp := superspin.New()
  str := "Hello there. {You should eat {fruits, veggies and grains|veggies, fruits and grains|fruits, grains and veggies|grains, fruits and veggies|veggies, grains and fruits|grains, veggies and fruits} if you want to be healthy.|If you want to be healthy, you should eat {fruits, veggies and grains|veggies, fruits and grains|fruits, grains and veggies|grains, fruits and veggies|veggies, grains and fruits|grains, veggies and fruits}.}"

  spinText := superspin.Spin(str)
}

That's it

Methods

Javascript/Node.js

constructor

new Superspin(openToken, closeToken, orToken)

default params:

  • openToken = {
  • closeToken = {
  • orToken = |

spin(String text[, Boolean withSeed])

Do spin a text with random seed. If withSeed set to true, then it will generate static result based on seed. Useful for a unique spun text.

seed(String str)

Set superspin seed. This seed will be used as seed generator if spin second argument set to true.

Golang

See godocs or superspin_test.go source

License

MIT

superspin's People

Contributors

raitucarp avatar vladchekunov avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

vladchekunov

superspin's Issues

Wrong encoding with non-ascii symbol sentences

If you want to using non-ascii symbols in sentences, you will get wrong encoding.

Already fixed that by changing 50 line of superspin.go:
char := rune(sp.text[i])
to
char := runes[i]
And adding variable runes before loop on line 49:
runes := []rune(sp.text)

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.