Skip to content

Instantly share code, notes, and snippets.

@nesslopz
nesslopz / toSlug.js
Created September 22, 2019 17:58 — forked from igor822/toSlug.js
String to Slug
String.prototype.toSlug = function(){
str = this.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "ãàáäâèéëêìíïîõòóöôùúüûñç·/_,:;";
var to = "aaaaaeeeeiiiiooooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@nesslopz
nesslopz / README.md
Last active March 19, 2016 17:50 — forked from clauswitt/distance.js
Get the distance between two (world) coordinates - a nodejs module

distance.js

NodeJs module to calc distances between two points using coords. Originally cloned from https://gist.github.com/1604972. Response is in km

Installation

npm install distance.js --save

Usage