Skip to content

Instantly share code, notes, and snippets.

View blinkylights23's full-sized avatar

Paul Smith blinkylights23

  • Paris, France
  • 12:55 (UTC +02:00)
View GitHub Profile
Machine({
id: 'pub',
initial: 'unpublished',
context: {
arcId: null
},
states: {
unpublished: {
on: {
PUBLISH: {
@blinkylights23
blinkylights23 / machine.js
Last active July 10, 2020 10:28
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'pub',
initial: 'unpublished',
context: {
arcId: null
},
states: {
unpublished: {
on: {
PUBLISH: {
function slugify(text) {
return text.toString().toLowerCase().trim()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}