Comparing version 1.2.2 to 1.2.3
{ | ||
"name": "str", | ||
"version": "1.2.2", | ||
"description": "", | ||
"version": "1.2.3", | ||
"description": "⚙️ String manipulation library", | ||
"main": "index.js", | ||
@@ -10,49 +10,51 @@ "scripts": { | ||
"watch:docs": "npx nodemon --watch ./scripts/docs/tmpl --watch ./scripts/docs/static/styles --watch ./scripts/docs/static/scripts --ext tmpl,css,js --exec \"npm run build:docs\"", | ||
"build:code": "npx babel-node ./scripts/build.js", | ||
"build": "rollup -c", | ||
"build:docs": "rm -fr ./docs && jsdoc -c .jsdoc.json -R ./README.md", | ||
"postbuild:docs": "git add . && git com -am 'Deploy' && git push && npm version patch -m 'fix individual methods import' && npm publish ./dist", | ||
"deploy": "npm run build:code", | ||
"deploy": "npm run build", | ||
"predeploy": "npm test", | ||
"postdeploy": "npx codecov -t 324aaa4d-c06b-49df-941b-8566b195f430 && npm run build:docs" | ||
"postdeploy": "npx codecov -t 324aaa4d-c06b-49df-941b-8566b195f430 && npm run build:docs", | ||
"browser:test": "npx serve ./", | ||
"prebrowser:test": "npm run build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/manelgarcia/str.git" | ||
"url": "git+https://github.com/manelet/str.git" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"keywords": ["str", "string manipulation", "slugify"], | ||
"author": "Manel Escuer", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/manelgarcia/str/issues" | ||
"url": "https://github.com/manelet/str/issues" | ||
}, | ||
"homepage": "https://github.com/manelgarcia/str#readme", | ||
"homepage": "https://github.com/manelet/str#readme", | ||
"devDependencies": { | ||
"@babel/cli": "^7.2.3", | ||
"@babel/core": "^7.4.0", | ||
"@babel/node": "^7.2.2", | ||
"@babel/plugin-proposal-class-properties": "^7.4.0", | ||
"@babel/plugin-transform-modules-commonjs": "^7.4.0", | ||
"@babel/plugin-transform-runtime": "^7.4.0", | ||
"@babel/polyfill": "^7.4.0", | ||
"@babel/preset-env": "^7.4.2", | ||
"@babel/register": "^7.4.0", | ||
"babel-plugin-add-module-exports": "^1.0.0", | ||
"babel-plugin-transform-import-paths": "^1.0.1", | ||
"@babel/cli": "^7.11.6", | ||
"@babel/core": "^7.11.6", | ||
"@babel/node": "^7.10.5", | ||
"@babel/plugin-external-helpers": "^7.10.4", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/plugin-transform-modules-commonjs": "^7.10.4", | ||
"@babel/plugin-transform-runtime": "^7.11.5", | ||
"@babel/polyfill": "^7.11.5", | ||
"@babel/preset-env": "^7.11.5", | ||
"@babel/register": "^7.11.5", | ||
"@rollup/plugin-babel": "^5.2.1", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"babel-plugin-add-module-exports": "^1.0.4", | ||
"babel-plugin-transform-import-paths": "^1.0.3", | ||
"chai": "^4.2.0", | ||
"codecov": "^3.1.0", | ||
"jsdoc": "^3.5.5", | ||
"codecov": "^3.7.2", | ||
"eslint-utils": "^1.4.3", | ||
"jsdoc": "^3.6.5", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.2.0", | ||
"rimraf": "^2.6.3", | ||
"rollup": "^1.7.3", | ||
"rollup-plugin-babel": "^4.3.2", | ||
"nyc": "^14.1.1", | ||
"rimraf": "^2.7.1", | ||
"rollup": "^1.32.1", | ||
"rollup-plugin-cleanup": "^3.1.1", | ||
"rollup-plugin-commonjs": "^9.2.2", | ||
"rollup-plugin-node-resolve": "^4.0.1", | ||
"rollup-plugin-copy": "^3.3.0", | ||
"rollup-plugin-terser": "^4.0.4", | ||
"rollup-plugin-uglify": "^6.0.2", | ||
"source-map-support": "^0.5.11", | ||
"standard": "^12.0.1" | ||
}, | ||
"dependencies": {} | ||
"type": "module" | ||
} |
116
str.js
@@ -1,76 +0,53 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = global || self, global.str = factory()); | ||
}(this, function () { 'use strict'; | ||
'use strict'; | ||
var trim = function trim(str) { | ||
return str.replace(/^\s+/, '').replace(/\s+$/, ''); | ||
}; | ||
const trim = str => str.replace(/^\s+/, '').replace(/\s+$/, ''); | ||
var slugify = function slugify(str, sep) { | ||
if (sep === void 0) { | ||
sep = '-'; | ||
} | ||
return trim(str).toLowerCase().replace(/ /g, sep) | ||
.normalize('NFD') | ||
.replace(/[\u0300-\u036f]/g, ''); | ||
}; | ||
const slugify = (str, sep = '-') => trim(str).toLowerCase().replace(/ /g, sep) | ||
.normalize('NFD') | ||
.replace(/[\u0300-\u036f]/g, ''); | ||
var lower = (function (str) { | ||
return str.toLowerCase(); | ||
}); | ||
var lower = (str => str.toLowerCase()); | ||
var count = (function (str) { | ||
return String(str).length; | ||
}); | ||
var count = (str => String(str).length); | ||
var upper = (function (str) { | ||
return String(str).toUpperCase(); | ||
}); | ||
var upper = (str => String(str).toUpperCase()); | ||
var startsWith = (function (str, sub, pos) { | ||
if (pos === void 0) { | ||
pos = 0; | ||
} | ||
return String(str).indexOf(sub, pos) === pos; | ||
}); | ||
var startsWith = ((str, sub, pos = 0) => String(str).indexOf(sub, pos) === pos); | ||
var endsWith = function endsWith(str, sub, pos) { | ||
str = String(str); | ||
if (!pos || typeof pos !== 'number' || !isFinite(pos) || Math.floor(pos) !== pos || pos > str.length) { | ||
pos = str.length; | ||
} | ||
pos -= sub.length; | ||
var index = str.indexOf(sub, pos - 1); | ||
return index !== -1 && index === pos; | ||
}; | ||
const endsWith = (str, sub, pos) => { | ||
str = String(str); | ||
if (!pos || typeof pos !== 'number' || !isFinite(pos) || Math.floor(pos) !== pos || pos > str.length) { | ||
pos = str.length; | ||
} | ||
pos -= sub.length; | ||
const index = str.indexOf(sub, pos - 1); | ||
return index !== -1 && index === pos; | ||
}; | ||
var capitalize = (function (str) { | ||
str = trim(str); | ||
return String(str.charAt(0).toUpperCase()) + String(str.slice(1).toLowerCase()); | ||
}); | ||
var capitalize = (str => { | ||
str = trim(str); | ||
return String(str.charAt(0).toUpperCase()) + String(str.slice(1).toLowerCase()); | ||
}); | ||
var functions = { | ||
count: count, | ||
slugify: slugify, | ||
lower: lower, | ||
upper: upper, | ||
trim: trim, | ||
startsWith: startsWith, | ||
endsWith: endsWith, | ||
capitalize: capitalize | ||
}; | ||
var camelcase = (string => trim(string).toLowerCase().split(' ').reduce((acc, word, i) => acc + (i === 0 ? word : capitalize(word)), '')); | ||
var NOT_CHAINABLE = ['count', 'startsWith', 'endsWith']; | ||
var Str = function Str(value) { | ||
var _this = this; | ||
var functions = { | ||
count, | ||
slugify, | ||
lower, | ||
upper, | ||
trim, | ||
startsWith, | ||
endsWith, | ||
capitalize, | ||
camelcase | ||
}; | ||
const NOT_CHAINABLE = ['count', 'startsWith', 'endsWith']; | ||
class Str { | ||
constructor(value) { | ||
this.value = value; | ||
Object.keys(functions).map(function (f) { | ||
_this[f] = function () { | ||
var _functions$f; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var r = (_functions$f = functions[f]).call.apply(_functions$f, [null, this.value].concat(args)); | ||
Object.keys(functions).map(f => { | ||
this[f] = function (...args) { | ||
const r = functions[f].call(null, this.value, ...args); | ||
if (NOT_CHAINABLE.includes(f)) { | ||
@@ -84,9 +61,8 @@ return r; | ||
this.length = this.count(this.value); | ||
}; | ||
function str(value) { | ||
return new Str(value); | ||
} | ||
} | ||
function str(value) { | ||
return new Str(value); | ||
} | ||
return str; | ||
})); | ||
module.exports = str; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
Yes
6189
4
112
1
2
0
2