Comparing version 0.1.1 to 0.1.2
33
index.js
@@ -51,5 +51,5 @@ /*! | ||
opts = opts || {}; | ||
var ch = character(opts, fn); | ||
var chars = character(opts, fn); | ||
return function(lvl, str) { | ||
return function(lvl, str, sublvl) { | ||
if (lvl == null) { | ||
@@ -60,2 +60,3 @@ throw new Error('[listitem]: invalid arguments.'); | ||
lvl = isNumber(lvl) ? +lvl : 0; | ||
var ch = chars(sublvl); | ||
@@ -83,2 +84,4 @@ var bullet = ch && ch[lvl % ch.length]; | ||
* | ||
* TODO: split this out into simpler functions. | ||
* | ||
* @param {Object} `opts` Options to pass to [expand-range] | ||
@@ -91,10 +94,26 @@ * @param {Function} `fn` | ||
var chars = opts.chars || ['-', '*', '+', '~']; | ||
if (typeof chars === 'string') { | ||
opts = Object.create(opts || {}); | ||
return expand(chars, opts, fn); | ||
return function (sublvl) { | ||
return expand(chars, opts, function(ch) { | ||
return fn ? fn(ch, sublvl) : ch; | ||
}); | ||
} | ||
} | ||
return typeof fn === 'function' | ||
? chars.map(fn) | ||
: chars; | ||
if (typeof fn === 'function') { | ||
return wrap(fn, chars); | ||
} | ||
return function () { | ||
return chars; | ||
} | ||
} | ||
function wrap (fn, chars) { | ||
return function (sublvl) { | ||
var args = [].slice.call(arguments); | ||
return chars.map(function (ch) { | ||
var ctx = args.concat.apply([], arguments); | ||
return fn.apply(fn, ctx); | ||
}); | ||
} | ||
} |
{ | ||
"name": "list-item", | ||
"description": "Generate a single formatted list item, allowing you to easily generate lists with proper indentation, bullets, numbers or other leading characters.", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"homepage": "https://github.com/jonschlinkert/list-item", | ||
@@ -6,0 +6,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7980
100