Socket
Socket
Sign inDemoInstall

morphling

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

morphling - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

.babelrc

4

index.js

@@ -1,1 +0,3 @@

export default require('./src');
import Morphling from './dist';
export default Morphling;

@@ -6,18 +6,16 @@ {

"name": "morphling",
"version": "0.3.2",
"version": "0.4.0",
"description": "A collection of VueJs filters.",
"main": "index.js",
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-preset-es2015": "^6.24.1",
"css-loader": "^0.28.4",
"style-loader": "^0.18.2",
"uglify-loader": "^2.0.0",
"webpack": "^3.5.4"
"babel-preset-stage-2": "^6.24.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rm -rf dist && webpack --progress --hide-modules"
"babel": "babel-node --presets es2015,stage-2",
"prebuild": "rm -rf dist",
"build": "babel src -d dist --copy-files"
},

@@ -24,0 +22,0 @@ "repository": {

@@ -5,3 +5,3 @@ # Mophling

It's MORPHLING time! **plays power ranger theme song.* 😂
It's MORPHLING time! **plays power ranger theme song.* *pun intented* 😂

@@ -8,0 +8,0 @@ ## Contents

export default (Vue) => {
const re = /(?:[A-Za-z0-9!#$%&'*+=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[A-Za-z0-9-]*[A-Za-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/gi
const re = /(?:[A-Za-z0-9!#$%&'*+=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[A-Za-z0-9-]*[A-Za-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/gi
Vue.directive('morph-email', {
bind
});
Vue.directive('morph-email', {
bind
});
function bind(el, binding, vnode) {
var s = vnode.elm.innerText;
const m = s.match(re);
const a = [];
var prev;
function bind(el, binding, vnode) {
var s = vnode.elm.innerText;
const m = s.match(re);
const a = [];
var prev;
if(!m) return;
if(!m) return;
console.warn(m)
console.warn(m)
if(m.length === 1){
el.innerHTML = s.replace(m[0], convertToA(m[0], binding));
return;
}
m.forEach((email, i, arr) => {
console.warn(email)
if(i % 2 === 0) {
prev = s.replace(email, convertToA(email, binding));
} else {
s = prev.replace(email, convertToA(email, binding));
}
});
el.innerHTML = s;
if(m.length === 1){
el.innerHTML = s.replace(m[0], convertToA(m[0], binding));
return;
}
function convertToA(email, binding) {
return `<a target="_blank" href="mailto:${ email }">${ email }</a>`;
}
m.forEach((email, i, arr) => {
console.warn(email)
if(i % 2 === 0) {
prev = s.replace(email, convertToA(email, binding));
} else {
s = prev.replace(email, convertToA(email, binding));
}
});
el.innerHTML = s;
}
function convertToA(email, binding) {
return `<a target="_blank" href="mailto:${ email }">${ email }</a>`;
}
};

@@ -5,4 +5,4 @@ import url from './url';

export default (Vue) => {
url(Vue);
// email(Vue);
url(Vue);
// email(Vue);
}
export default (Vue) => {
const re = /\b(https|http|ftp)?:\/\/\S+/gi
const re = /\b(https|http|ftp)?:\/\/\S+/gi
Vue.directive('morph-url', {
bind
});
Vue.directive('morph-url', {
bind
});
function bind(el, binding, vnode) {
var s = vnode.elm.innerText;
const m = s.match(re);
const a = [];
var prev;
function bind(el, binding, vnode) {
var s = vnode.elm.innerText;
const m = s.match(re);
const a = [];
var prev;
if(!m) return;
if(!m) return;
if(m.length === 1){
el.innerHTML = s.replace(m[0], convertToA(m[0], binding));
return;
}
m.forEach((link, i, arr) => {
if(i % 2 === 0) {
prev = s.replace(link, convertToA(link, binding))
} else {
s = prev.replace(link, convertToA(link, binding))
}
});
el.innerHTML = s;
if(m.length === 1){
el.innerHTML = s.replace(m[0], convertToA(m[0], binding));
return;
}
function convertToA(link, binding) {
return `<a target="_blank" href="${ link }" style="${ binding.value }">${ link }</a>`;
}
m.forEach((link, i, arr) => {
if(i % 2 === 0) {
prev = s.replace(link, convertToA(link, binding))
} else {
s = prev.replace(link, convertToA(link, binding))
}
});
el.innerHTML = s;
}
function convertToA(link, binding) {
return `<a target="_blank" href="${ link }" style="${ binding.value }">${ link }</a>`;
}
};
export default (Vue) => {
Vue.filter('morph-capitalize', (value) => {
if(!value) return;
return capitalize(value);
});
Vue.filter('morph-capitalize', (value) => {
if(!value) return;
return capitalize(value);
});
Vue.prototype.$morphCapitalize = (value) => {
return capitalize(value);
};
Vue.prototype.$morphCapitalize = (value) => {
return capitalize(value);
};
function capitalize(value) {
if(typeof value !== 'string') value = value.toString();
return `${ value.charAt(0).toUpperCase() }${ value.substring(1) }`;
}
function capitalize(value) {
if(typeof value !== 'string') value = value.toString();
return `${ value.charAt(0).toUpperCase() }${ value.substring(1) }`;
}
};
export default (Vue) => {
Vue.filter('morph-chop', (value, length, location) => {
if(!value) return;
return chop(value, length, location);
});
Vue.filter('morph-chop', (value, length, location) => {
if(!value) return;
return chop(value, length, location);
});
Vue.prototype.$morphChop = (value, length, location) => {
return chop(value, length, location);
};
Vue.prototype.$morphChop = (value, length, location) => {
return chop(value, length, location);
};
function chop(value, length, location) {
if(!length) return 'Warn: option length (number) is required. morph-chop(length, location)'
if(!location) location = 'end';
if(typeof value !== 'string') value = value.toString();
if(location === 'end')
return value.toString().slice(0, ~length+1)
if(location === 'start')
return value.toString().substring(length);
}
function chop(value, length, location) {
if(!length) return 'Warn: option length (number) is required. morph-chop(length, location)'
if(!location) location = 'end';
if(typeof value !== 'string') value = value.toString();
if(location === 'end')
return value.toString().slice(0, ~length+1)
if(location === 'start')
return value.toString().substring(length);
}
};
import currencies from '../../lib/currencies';
export default (Vue) => {
Vue.filter('morph-currency', (value, code, useSymbol) => {
if(!value) return;
return sandwich(value, code, useSymbol);
});
Vue.filter('morph-currency', (value, code, useSymbol) => {
if(!value) return;
return sandwich(value, code, useSymbol);
});
Vue.prototype.$morphCurrency = (value, code, useSymbol) => {
return sandwich(value, code, useSymbol);
};
Vue.prototype.$morphCurrency = (value, code, useSymbol) => {
return sandwich(value, code, useSymbol);
};
function sandwich(value, code, useSymbol) {
let preffix = '';
if(!code) code = 'USD';
let match = currencies.filter(item => code === item.code);
if(match.length === 0) {
preffix = '$';
console.warn(`Morphling Warn: The provided code '${ code }' does not exist. Replaced with default $ symbol.`);
} else {
preffix = match[0].symbol;
}
return `${ preffix }${ value }`;
function sandwich(value, code, useSymbol) {
let preffix = '';
if(!code) code = 'USD';
let match = currencies.filter(item => code === item.code);
if(match.length === 0) {
preffix = '$';
console.warn(`Morphling Warn: The provided code '${ code }' does not exist. Replaced with default $ symbol.`);
} else {
preffix = match[0].symbol;
}
return `${ preffix }${ value }`;
}
};

@@ -1,16 +0,16 @@

import * as moment from 'moment';
import moment from 'moment';
export default (Vue) => {
Vue.filter('morph-date', (value, format) => {
if(!value) return;
return morphDate(value, format);
});
Vue.filter('morph-date', (value, format) => {
if(!value) return;
return morphDate(value, format);
});
Vue.prototype.$morphDate = (value, format) => {
return morphDate(value, format);
};
Vue.prototype.$morphDate = (value, format) => {
return morphDate(value, format);
};
function morphDate(value, format) {
return moment(value).format(format);
}
function morphDate(value, format) {
return moment(value).format(format);
}
};

@@ -15,14 +15,14 @@ import capitalize from './capitalize';

export default (Vue) => {
capitalize(Vue);
chop(Vue);
currency(Vue);
date(Vue);
json(Vue);
lowercase(Vue);
placeholder(Vue);
replace(Vue);
reverse(Vue);
sandwich(Vue);
truncate(Vue);
uppercase(Vue);
capitalize(Vue);
chop(Vue);
currency(Vue);
date(Vue);
json(Vue);
lowercase(Vue);
placeholder(Vue);
replace(Vue);
reverse(Vue);
sandwich(Vue);
truncate(Vue);
uppercase(Vue);
};
export default (Vue) => {
Vue.filter('morph-json', (value, indent) => {
if(!value) return;
return json(value, indent);
});
Vue.filter('morph-json', (value, indent) => {
if(!value) return;
return json(value, indent);
});
Vue.prototype.$morphJson = (value, indent) => {
return json(value, indent);
};
Vue.prototype.$morphJson = (value, indent) => {
return json(value, indent);
};
function json(value, indent) {
return JSON.stringify(value, null, indent);
}
function json(value, indent) {
return JSON.stringify(value, null, indent);
}
};
export default (Vue) => {
Vue.filter('morph-lowercase', (value) => {
if(!value) return;
return lowercase(value);
});
Vue.filter('morph-lowercase', (value) => {
if(!value) return;
return lowercase(value);
});
Vue.prototype.$morphLowercase = (value) => {
return lowercase(value);
};
Vue.prototype.$morphLowercase = (value) => {
return lowercase(value);
};
function lowercase(value) {
if(typeof value !== 'string') value = value.toString();
return value.toLowerCase();
}
function lowercase(value) {
if(typeof value !== 'string') value = value.toString();
return value.toLowerCase();
}
};
export default (Vue) => {
Vue.filter('morph-placeholder', (value, placeholder) => {
if(!value) return;
return replace(value, placeholder);
});
Vue.filter('morph-placeholder', (value, placeholder) => {
if(!value) return;
return replace(value, placeholder);
});
Vue.prototype.$morphPlaceholder = (value, placeholder) => {
console.log(placeholder)
return replace(value, placeholder);
};
Vue.prototype.$morphPlaceholder = (value, placeholder) => {
console.log(placeholder)
return replace(value, placeholder);
};
function replace(value, placeholder) {
return placeholder;
}
function replace(value, placeholder) {
return placeholder;
}
};
export default (Vue) => {
Vue.filter('morph-replace', (value, replacee, replacer) => {
if(!value) return;
return replace(value, replacee, replacer);
});
Vue.filter('morph-replace', (value, replacee, replacer) => {
if(!value) return;
return replace(value, replacee, replacer);
});
Vue.prototype.$morphReplace = (value, replacee, replacer) => {
return replace(value, replacee, replacer);
};
Vue.prototype.$morphReplace = (value, replacee, replacer) => {
return replace(value, replacee, replacer);
};
function replace(value, replacee, replacer) {
return value.replace(replacee, replacer);
}
function replace(value, replacee, replacer) {
return value.replace(replacee, replacer);
}
};
export default (Vue) => {
Vue.filter('morph-reverse', (value) => {
if(!value) return;
return reverse(value);
});
Vue.filter('morph-reverse', (value) => {
if(!value) return;
return reverse(value);
});
Vue.prototype.$morphReverse = (value) => {
return reverse(value);
};
Vue.prototype.$morphReverse = (value) => {
return reverse(value);
};
function reverse(value) {
if(typeof value !== 'string') value = value.toString();
return value.split('').reverse().join('');
}
function reverse(value) {
if(typeof value !== 'string') value = value.toString();
return value.split('').reverse().join('');
}
};

@@ -14,25 +14,25 @@ const corpus = {

export default (Vue) => {
Vue.filter('morph-sandwich', (value, start, end) => {
if(!value) return;
return sandwich(value, start, end);
});
Vue.filter('morph-sandwich', (value, start, end) => {
if(!value) return;
return sandwich(value, start, end);
});
Vue.prototype.$morphSandwich = (value, start, end) => {
return sandwich(value, start, end);
};
Vue.prototype.$morphSandwich = (value, start, end) => {
return sandwich(value, start, end);
};
function flip (str) {
return str.replace(corpusRegex, match => corpus[match])
.split('')
.reverse()
.join('');
}
function flip (str) {
return str.replace(corpusRegex, match => corpus[match])
.split('')
.reverse()
.join('');
}
function sandwich(value, start, end) {
start = start || '';
end = end || flip(start);
function sandwich(value, start, end) {
start = start || '';
end = end || flip(start);
return `${ start }${ value }${ end }`;
}
return `${ start }${ value }${ end }`;
}
};
export default (Vue) => {
Vue.filter('morph-truncate', (value, length) => {
if(!value) return;
return truncate(value, length);
});
Vue.filter('morph-truncate', (value, length) => {
if(!value) return;
return truncate(value, length);
});
Vue.prototype.$morphTruncate = (value, length) => {
return truncate(value, length);
};
Vue.prototype.$morphTruncate = (value, length) => {
return truncate(value, length);
};
function truncate(value, length) {
if(value.length < length) {
console.warn('Morphling Warn: trucate value cannot be greater than string length.')
}
return `${ value.substr(0, length) }...`
function truncate(value, length) {
if(value.length < length) {
console.warn('Morphling Warn: trucate value cannot be greater than string length.')
}
return `${ value.substr(0, length) }...`
}
};
export default (Vue) => {
Vue.filter('morph-uppercase', (value) => {
if(!value) return;
return value.toUpperCase();
});
Vue.filter('morph-uppercase', (value) => {
if(!value) return;
return value.toUpperCase();
});
Vue.prototype.$morphUppercase = (value) => {
return value.toUpperCase();
};
Vue.prototype.$morphUppercase = (value) => {
return value.toUpperCase();
};
};

@@ -5,8 +5,8 @@ import filters from './filters';

const Morphling = {
install(Vue, options) {
filters(Vue, options);
directives(Vue);
}
install(Vue, options) {
filters(Vue, options);
directives(Vue);
}
}
export default Morphling;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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