@bbob/core
Advanced tools
Comparing version 1.1.0 to 2.0.0
@@ -1,37 +0,39 @@ | ||
const parser = require('@bbob/parser'); | ||
const render = require('@bbob/html'); | ||
'use strict'; | ||
const { iterate, match } = require('./utils'); | ||
exports.__esModule = true; | ||
exports.default = bbob; | ||
var _parser = require('@bbob/parser'); | ||
var _utils = require('./utils'); | ||
function walk(cb) { | ||
return iterate(this, cb); | ||
return (0, _utils.iterate)(this, cb); | ||
} | ||
module.exports = function bbob(plugs) { | ||
const plugins = typeof plugs === 'function' ? [plugs] : plugs || []; | ||
function bbob(plugs) { | ||
var plugins = typeof plugs === 'function' ? [plugs] : plugs || []; | ||
let options = { | ||
skipParse: false, | ||
var options = { | ||
skipParse: false | ||
}; | ||
return { | ||
process(input, opts) { | ||
process: function process(input, opts) { | ||
options = opts || {}; | ||
const parseFn = options.parser || parser; | ||
const renderFn = options.render || render; | ||
var parseFn = options.parser || _parser.parse; | ||
var renderFn = options.render; | ||
let tree = options.skipParse | ||
? input || [] | ||
: parseFn(input, options); | ||
var tree = options.skipParse ? input || [] : parseFn(input, options); | ||
tree.walk = walk; | ||
tree.match = match; | ||
tree.match = _utils.match; | ||
plugins.forEach((plugin) => { | ||
plugins.forEach(function (plugin) { | ||
tree = plugin(tree, { | ||
parse: parseFn, | ||
render: renderFn, | ||
iterate, | ||
match, | ||
iterate: _utils.iterate, | ||
match: _utils.match | ||
}) || tree; | ||
@@ -42,9 +44,12 @@ }); | ||
get html() { | ||
if (typeof renderFn !== 'function') { | ||
throw new Error('"render" function not defined, please pass to "process(input, { render })"'); | ||
} | ||
return renderFn(tree, tree.options); | ||
}, | ||
tree, | ||
messages: tree.messages, | ||
tree: tree, | ||
messages: tree.messages | ||
}; | ||
}, | ||
} | ||
}; | ||
}; | ||
} |
@@ -0,10 +1,17 @@ | ||
'use strict'; | ||
exports.__esModule = true; | ||
/* eslint-disable no-plusplus */ | ||
const isObj = value => (typeof value === 'object'); | ||
const isBool = value => (typeof value === 'boolean'); | ||
var isObj = function isObj(value) { | ||
return typeof value === 'object'; | ||
}; | ||
var isBool = function isBool(value) { | ||
return typeof value === 'boolean'; | ||
}; | ||
function iterate(t, cb) { | ||
const tree = t; | ||
var tree = t; | ||
if (Array.isArray(tree)) { | ||
for (let idx = 0; idx < tree.length; idx++) { | ||
for (var idx = 0; idx < tree.length; idx++) { | ||
tree[idx] = iterate(cb(tree[idx]), cb); | ||
@@ -29,8 +36,12 @@ } | ||
if (Array.isArray(expected)) { | ||
return expected.every(exp => [].some.call(actual, act => same(exp, act))); | ||
return expected.every(function (exp) { | ||
return [].some.call(actual, function (act) { | ||
return same(exp, act); | ||
}); | ||
}); | ||
} | ||
return Object.keys(expected).every((key) => { | ||
const ao = actual[key]; | ||
const eo = expected[key]; | ||
return Object.keys(expected).every(function (key) { | ||
var ao = actual[key]; | ||
var eo = expected[key]; | ||
@@ -50,18 +61,16 @@ if (isObj(eo) && eo !== null && ao !== null) { | ||
function match(expression, cb) { | ||
return Array.isArray(expression) | ||
? iterate(this, (node) => { | ||
for (let idx = 0; idx < expression.length; idx++) { | ||
if (same(expression[idx], node)) { | ||
return cb(node); | ||
} | ||
return Array.isArray(expression) ? iterate(this, function (node) { | ||
for (var idx = 0; idx < expression.length; idx++) { | ||
if (same(expression[idx], node)) { | ||
return cb(node); | ||
} | ||
} | ||
return node; | ||
}) | ||
: iterate(this, node => (same(expression, node) ? cb(node) : node)); | ||
return node; | ||
}) : iterate(this, function (node) { | ||
return same(expression, node) ? cb(node) : node; | ||
}); | ||
} | ||
module.exports = { | ||
iterate, | ||
match, | ||
}; | ||
exports.iterate = iterate; | ||
exports.match = match; |
{ | ||
"name": "@bbob/core", | ||
"version": "1.1.0", | ||
"description": "BBob is a tool to transform BBCode markup useing presets", | ||
"main": "lib/index.js", | ||
"directories": { | ||
"lib": "lib" | ||
}, | ||
"dependencies": { | ||
"@bbob/html": "^1.1.0", | ||
"@bbob/parser": "^1.2.0" | ||
}, | ||
"peerDependencies": { | ||
"@bbob/preset-html5": "^1.x" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/JiLiZART/bbob.git" | ||
}, | ||
"version": "2.0.0", | ||
"description": "Fast, flexible, and lean implementation of BBcode parser with plugins", | ||
"keywords": [ | ||
"bbcode", | ||
"parser", | ||
"fast", | ||
"bbcode parser", | ||
"bbcodeparser", | ||
"bbob", | ||
"serializer", | ||
"bbcode serializer", | ||
"bbcode serializer", | ||
"bbcodeserializer", | ||
"parse", | ||
"serialize", | ||
"html", | ||
"transform" | ||
], | ||
"dependencies": { | ||
"@bbob/parser": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@bbob/html": "^2.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@bbob/html": "^1.x", | ||
"@bbob/preset-html5": "^1.x", | ||
"@bbob/preset-react": "^1.x", | ||
"@bbob/react": "^1.x" | ||
}, | ||
"main": "lib/index.js", | ||
"module": "es/index.js", | ||
"jsnext:main": "es/index.js", | ||
"browser": "dist/index.js", | ||
"browserName": "BbobCore", | ||
"homepage": "https://github.com/JiLiZART/bbob", | ||
"author": "Nikolay Kostyurin <jilizart@gmail.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/JiLiZART/bbob/issues" | ||
}, | ||
"homepage": "https://github.com/JiLiZART/bbob#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/JiLiZART/bbob.git" | ||
}, | ||
"scripts": { | ||
"build:commonjs": "../../node_modules/.bin/cross-env BABEL_ENV=commonjs ../../node_modules/.bin/babel src --out-dir lib", | ||
"build:es": "../../node_modules/.bin/cross-env BABEL_ENV=es ../../node_modules/.bin/babel src --out-dir es", | ||
"build:umd": "../../node_modules/.bin/cross-env BABEL_ENV=rollup NODE_ENV=development ../../node_modules/.bin/rollup --config ../../rollup.config.js", | ||
"build": "npm run build:commonjs && npm run build:es && npm run build:umd", | ||
"test": "../../node_modules/.bin/jest --", | ||
"cover": "../../node_modules/.bin/jest --coverage", | ||
"lint": "../../node_modules/.bin/eslint ." | ||
"lint": "../../node_modules/.bin/eslint .", | ||
"size": "../../node_modules/.bin/size-limit" | ||
}, | ||
"author": "Nikolay Kostyurin <jilizart@gmail.com>", | ||
"license": "MIT", | ||
"size-limit": [ | ||
{ | ||
"path": "lib/index.js" | ||
} | ||
], | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org/" | ||
} | ||
}, | ||
"files": [ | ||
"dist", | ||
"lib", | ||
"src", | ||
"es" | ||
] | ||
} |
@@ -7,8 +7,9 @@ # @bbob/core | ||
const bbob = require('@bbob/core'); | ||
const render = require('@bbob/html'); | ||
const presetHTML5 = require('@bbob/preset-html5'); | ||
const code = `[i]Text[/i]`; | ||
const html = bbob([presetHTML5()]).process(code).html; | ||
const html = bbob([presetHTML5()]).process(code, { render }).html; | ||
console.log(html); // <span style="font-style: italic;">Text</span> | ||
``` |
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
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
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
57887
11
1839
15
5
1
1
+ Added@bbob/core@1.1.0(transitive)
+ Added@bbob/parser@2.9.0(transitive)
+ Added@bbob/plugin-helper@2.9.0(transitive)
+ Added@bbob/react@1.1.0(transitive)
+ Addedasap@2.0.6(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addedcreate-react-class@15.7.0(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedfbjs@0.8.18(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisomorphic-fetch@2.2.1(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedpromise@7.3.1(transitive)
+ Addedprop-types@15.8.1(transitive)
+ Addedreact@15.7.0(transitive)
+ Addedreact-is@16.13.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedua-parser-js@0.7.39(transitive)
+ Addedwhatwg-fetch@3.6.20(transitive)
- Removed@bbob/html@^1.1.0
Updated@bbob/parser@^2.0.0