protoblast
Advanced tools
Comparing version 0.6.5 to 0.6.6
@@ -0,1 +1,11 @@ | ||
## 0.6.6 (2019-02-25) | ||
* Add `String#allIndexesOf(needle)` to get an array of indexes | ||
* Speed up `String#tokenizeHTML(source)` when supplying custom blocks | ||
* Add `Function#enforceProperty(setter)` | ||
* Add `Blast.requireAll()` to require multiple files with the same options | ||
* Allow parent classes to override a child constructor with `modifyChildConstructor` function | ||
* Add simple `Magic` class, which supports Magic getters & setters by using proxies | ||
* Add `Blast.parseUseragent(ua)` to parse a useragent string | ||
## 0.6.5 (2019-02-18) | ||
@@ -2,0 +12,0 @@ |
@@ -320,3 +320,3 @@ module.exports = function BlastInheritance(Blast, Collection) { | ||
* @since 0.1.3 | ||
* @version 0.6.1 | ||
* @version 0.6.6 | ||
* | ||
@@ -520,3 +520,7 @@ * @param {String|Function|Array} _parent Parent class to inherit from | ||
inherits(super_constructor, namespace, newConstructor, _do_constitutors); | ||
temp = inherits(super_constructor, namespace, newConstructor, _do_constitutors); | ||
if (i == 0 && temp) { | ||
newConstructor = temp; | ||
} | ||
} | ||
@@ -531,2 +535,17 @@ | ||
let new_constructor_name = newConstructor.name; | ||
// Does the parent class need to do anything to the constructor? | ||
if (parentConstructor && typeof parentConstructor.modifyChildConstructor == 'function') { | ||
temp = parentConstructor.modifyChildConstructor(newConstructor); | ||
if (temp && temp != newConstructor) { | ||
temp = Collection.Function.create(new_constructor_name, temp); | ||
temp.staticChain = newConstructor.staticChain; | ||
temp.super = newConstructor.super; | ||
Blast.defineValue(temp, 'namespace', namespace); | ||
newConstructor = temp; | ||
} | ||
} | ||
// See if `setMethod` is available, if not this means | ||
@@ -607,5 +626,5 @@ // Protoblast was loaded without modifying the native objects | ||
// Construct the new path, including the namespace | ||
targetPath = namespace + '.' + newConstructor.name; | ||
targetPath = namespace + '.' + new_constructor_name; | ||
} else { | ||
targetPath = newConstructor.name; | ||
targetPath = new_constructor_name; | ||
} | ||
@@ -623,3 +642,3 @@ } | ||
ancestor : parentConstructor.name, | ||
descendant : newConstructor.name, | ||
descendant : new_constructor_name, | ||
namespace : namespace | ||
@@ -1373,2 +1392,41 @@ }; | ||
/** | ||
* Enforce a property: | ||
* Define a setter (which will be called on first get) | ||
* | ||
* @author Jelle De Loecker <jelle@develry.be> | ||
* @since 0.6.6 | ||
* @version 0.6.6 | ||
* | ||
* @param {Function} target Target object or function | ||
* @param {String} key Name to use (defaults to method name) | ||
* @param {Function} setter Function that returns a value | ||
*/ | ||
Blast.defineStatic('Function', function enforceProperty(target, key, setter, enumerable) { | ||
var symbol, | ||
keys; | ||
if (typeof key === 'function') { | ||
enumerable = setter; | ||
setter = key; | ||
keys = Collection.Array.cast(setter.name || undefined); | ||
} else { | ||
keys = Collection.Array.cast(key); | ||
} | ||
symbol = Symbol(keys[0]); | ||
return Fn.setProperty(target, keys, function getter() { | ||
if (this[symbol] == null && !(symbol in this)) { | ||
this[symbol] = setter.call(this); | ||
} | ||
return this[symbol]; | ||
}, function _setter(value) { | ||
return this[symbol] = setter.call(this, value, this[symbol]); | ||
}); | ||
}); | ||
/** | ||
* Get all the children of a certain class | ||
@@ -1510,2 +1568,17 @@ * | ||
/** | ||
* Enforce a property: | ||
* Like `prepareProperty`, but with a setter | ||
* | ||
* @author Jelle De Loecker <jelle@develry.be> | ||
* @since 0.6.6 | ||
* @version 0.6.6 | ||
* | ||
* @param {String} key Name to use (defaults to method name) | ||
* @param {Function} setter Function that returns a value | ||
*/ | ||
var protoEnforceProperty = function enforceProperty(key, getter) { | ||
return Fn.enforceProperty(this, key, getter); | ||
}; | ||
/** | ||
* Prepare a static property: | ||
@@ -1598,2 +1671,3 @@ * the getter will supply the value on first get | ||
Blast.defineValue(newConstructor, protoPrepareProperty); | ||
Blast.defineValue(newConstructor, protoEnforceProperty); | ||
Blast.defineValue(newConstructor, protoDecorateMethod); | ||
@@ -1617,2 +1691,3 @@ Blast.defineValue(newConstructor, protoStaticCompose); | ||
Blast.definePrototype('Function', protoPrepareProperty); | ||
Blast.definePrototype('Function', protoEnforceProperty); | ||
Blast.definePrototype('Function', protoDecorateMethod); | ||
@@ -1619,0 +1694,0 @@ Blast.definePrototype('Function', protoStaticCompose); |
201
lib/init.js
@@ -30,2 +30,120 @@ module.exports = function BlastInitLoader(modifyPrototype) { | ||
const version_rx = /([0-9]+)\.([0-9]+)\.?([0-9]+\.?[0-9]*)?/ | ||
/** | ||
* Parse a useragent string | ||
* | ||
* @author Jelle De Loecker <jelle@develry.be> | ||
* @since 0.6.6 | ||
* @version 0.6.6 | ||
* | ||
* @param {String} useragent | ||
* | ||
* @return {Object} | ||
*/ | ||
function parseUseragent(ua) { | ||
var platform, | ||
webview = false, | ||
version, | ||
engine, | ||
result, | ||
major, | ||
minor, | ||
patch, | ||
float, | ||
index, | ||
name, | ||
temp, | ||
os; | ||
ua = ua.toLowerCase(); | ||
if (~ua.indexOf('mobile')) { | ||
platform = 'mobile'; | ||
} else if (~ua.indexOf('tablet')) { | ||
platform = 'tablet'; | ||
} else { | ||
platform = 'desktop'; | ||
} | ||
if (~(index = ua.indexOf('msie'))) { | ||
name = 'internet explorer'; | ||
platform = 'desktop'; | ||
} else if (~(index = ua.indexOf('trident/'))) { | ||
name = 'internet explorer'; | ||
platform = 'desktop'; | ||
index += 13; | ||
} else if (~(index = ua.indexOf('edge/'))) { | ||
name = 'edge'; | ||
engine = 'edgehtml'; | ||
} else if (~(index = ua.indexOf('chrome/'))) { | ||
name = 'chrome'; | ||
} else if (~(index = ua.indexOf('firefox/'))) { | ||
name = 'firefox'; | ||
engine = 'gecko'; | ||
} else if (~(index = ua.indexOf('safari/'))) { | ||
name = 'safari'; | ||
index = ua.indexOf('version/'); | ||
engine = 'webkit'; | ||
} | ||
if (~index) { | ||
version = version_rx.exec(ua.slice(index)); | ||
if (version) { | ||
float = parseFloat(version[0]); | ||
major = +version[1]; | ||
minor = +version[2]; | ||
patch = version[3] || ''; | ||
} | ||
} | ||
if (!engine) { | ||
switch (name) { | ||
case 'internet explorer': | ||
engine = 'trident'; | ||
break; | ||
case 'chrome': | ||
if (major < 28) { | ||
engine = 'webkit'; | ||
} else { | ||
engine = 'blink'; | ||
} | ||
break; | ||
} | ||
} | ||
if (platform != 'desktop') { | ||
if (~ua.indexOf('iphone') || ~ua.indexOf('ipad') || ~ua.indexOf('ipod')) { | ||
os = 'ios'; | ||
if (ua.indexOf('safari') == -1) { | ||
webview = true; | ||
} | ||
} else if (~ua.indexOf('; wv')) { | ||
webview = true; | ||
} | ||
} | ||
result = { | ||
family : name, | ||
version : { | ||
major : major, | ||
minor : minor, | ||
patch : patch, | ||
float : float | ||
}, | ||
platform : platform, | ||
engine : engine, | ||
webview : webview, | ||
os : os | ||
}; | ||
return result; | ||
} | ||
Blast.parseUseragent = parseUseragent; | ||
// Is it a pure, regular browser? | ||
@@ -71,20 +189,15 @@ Blast.isBrowser = false; | ||
ua = window.navigator.userAgent; | ||
ua = parseUseragent(window.navigator.userAgent); | ||
Blast.isIE = (ua.indexOf('MSIE') > -1 || ua.indexOf('Trident/') > -1); | ||
Blast.userAgent = ua; | ||
Blast.isIE = ua.browser == 'internet explorer'; | ||
if (!Blast.isIE) { | ||
Blast.isEdge = ua.indexOf('Edge/') > -1; | ||
Blast.isEdge = ua.browser == 'edge'; | ||
} | ||
if (!Blast.isEdge) { | ||
Blast.isiOS = /iphone|ipod|ipad/i.test(ua); | ||
if (Blast.isiOS) { | ||
// If safari is not part of the useragent string, it's a webview | ||
Blast.isWebview = !/safari/i.test(ua); | ||
} else { | ||
Blast.isWebview = ua.indexOf('; wv)') > -1; | ||
} | ||
Blast.isChrome = /Chrome/.test(ua); | ||
Blast.isiOS = ua.os == 'ios'; | ||
Blast.isWebview = ua.webview; | ||
Blast.isChrome = ua.family == 'chrome'; | ||
} | ||
@@ -250,2 +363,3 @@ } | ||
'JSONPath', | ||
'Magic', | ||
'Math', | ||
@@ -1084,2 +1198,7 @@ 'Map', | ||
* Check require call | ||
* | ||
* @author Jelle De Loecker <jelle@develry.be> | ||
* @version 0.6.6 | ||
* | ||
* @param {Object} options | ||
*/ | ||
@@ -1099,2 +1218,4 @@ function checkNextRequire(options) { | ||
var head; | ||
// Restore the original functions | ||
@@ -1113,3 +1234,13 @@ modulep.wrap = modulep.original_wrap; | ||
script = 'module.exports = function(Blast, Collection, Bound, Obj) {' + script + '\n};'; | ||
head = 'module.exports = function('; | ||
if (options.arguments) { | ||
head += options.arguments.names.join(','); | ||
} else { | ||
head += 'Blast, Collection, Bound, Obj'; | ||
} | ||
head += ') {'; | ||
script = head + script + '\n};'; | ||
} | ||
@@ -1137,2 +1268,21 @@ } | ||
/** | ||
* Require all given Protoblast modules | ||
* | ||
* @author Jelle De Loecker <jelle@develry.be> | ||
* @since 0.6.6 | ||
* @version 0.6.6 | ||
* | ||
* @param {String} name | ||
* @param {Object} options | ||
*/ | ||
Blast.requireAll = function requireAll(paths, options) { | ||
var i; | ||
for (i = 0; i < paths.length; i++) { | ||
Blast.require(paths[i], Object.assign({}, options)); | ||
} | ||
}; | ||
/** | ||
* Require a Protoblast module | ||
@@ -1142,3 +1292,3 @@ * | ||
* @since 0.4.1 | ||
* @version 0.5.1 | ||
* @version 0.6.6 | ||
* | ||
@@ -1152,3 +1302,4 @@ * @param {String} name | ||
exported_fnc, | ||
result; | ||
result, | ||
args; | ||
@@ -1173,2 +1324,12 @@ if (!options) { | ||
if (options.pwd) { | ||
if (!Array.isArray(name)) { | ||
name = [name]; | ||
} else { | ||
name = name.slice(0); | ||
} | ||
name.unshift(options.pwd); | ||
} | ||
if (Array.isArray(name)) { | ||
@@ -1206,4 +1367,10 @@ name = libpath.resolve.apply(libpath, name); | ||
if (options.arguments) { | ||
args = options.arguments.values; | ||
} else { | ||
args = [Blast, Collection, Blast.Bound, Blast.Bound.Object]; | ||
} | ||
// Execute the exported function | ||
result = exported_fnc(Blast, Collection, Blast.Bound, Blast.Bound.Object); | ||
result = exported_fnc.apply(null, args); | ||
@@ -1245,3 +1412,3 @@ if (result != null) { | ||
// Core files are already wrapped | ||
add_wrapper : false | ||
add_wrapper : null | ||
}; | ||
@@ -1248,0 +1415,0 @@ |
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
module.exports = function BlastJSON(Blast, Collection, Bound, Obj) { | ||
@@ -4,0 +2,0 @@ |
@@ -578,17 +578,20 @@ module.exports = function BlastString(Blast, Collection, Bound, Obj) { | ||
const NORMALIZE_TAG_REGEX = /<\/?([^\s\/>]+)/, | ||
STATE_PLAINTEXT = Symbol('plaintext'), | ||
STATE_HTML = Symbol('html'), | ||
STATE_COMMENT = Symbol('comment'), | ||
STATE_TAG_NAME = Symbol('tag_name'), | ||
STATE_WHITESPACE = Symbol('whitespace'), | ||
STATE_TAG_CONTENT = Symbol('tag_content'), | ||
STATE_ATTR_NAME = Symbol('attribute_name'), | ||
STATE_ATTR_VAL = Symbol('attribute_value'), | ||
STATE_SCRIPT = Symbol('script'), | ||
STATE_STRING_D = Symbol('string_double'), | ||
STATE_STRING_S = Symbol('string_single'), | ||
STATE_ATTR_IDENT = Symbol('identifier'); | ||
STATE = { | ||
PLAINTEXT : Symbol('plaintext'), | ||
HTML : Symbol('html'), | ||
COMMENT : Symbol('comment'), | ||
TAG_NAME : Symbol('tag_name'), | ||
WHITESPACE : Symbol('whitespace'), | ||
TAG_CONTENT : Symbol('tag_content'), | ||
ATTR_NAME : Symbol('attribute_name'), | ||
ATTR_VAL : Symbol('attribute_value'), | ||
SCRIPT : Symbol('script'), | ||
STRING_D : Symbol('string_double'), | ||
STRING_S : Symbol('string_single'), | ||
ATTR_IDENT : Symbol('identifier') | ||
}; | ||
Blast.REPLACE_BR_NEWLINE = Symbol('REPLACE_BR_NEWLINE'); | ||
Blast.REPLACE_OPEN_TAG_NEWLINE = Symbol('REPLACE_OPEN_TAG_NEWLINE'); | ||
Blast.HTML_TOKENIZER_STATES = STATE; | ||
@@ -617,3 +620,3 @@ /** | ||
* @since 0.6.5 | ||
* @version 0.6.5 | ||
* @version 0.6.6 | ||
* | ||
@@ -632,69 +635,82 @@ * @param {String source | ||
depth = 0, | ||
state = STATE_PLAINTEXT, | ||
state = STATE.PLAINTEXT, | ||
last_tag = '', | ||
do_continue, | ||
block_indexes_arr, | ||
block_indexes, | ||
prev_state, | ||
do_blocks = false, | ||
closing, | ||
blocks, | ||
close, | ||
block, | ||
open, | ||
char, | ||
end, | ||
key, | ||
i; | ||
if (options) { | ||
if (options && options.blocks) { | ||
blocks = options.blocks; | ||
} | ||
for (i = 0; i < length; i++) { | ||
char = source[i]; | ||
// Get all indexes in advance, so we don't need to check every char | ||
// to see if it matches a custom block | ||
for (key in blocks) { | ||
open = Bound.String.allIndexesOf(source, blocks[key].open); | ||
if (blocks) { | ||
do_continue = false; | ||
if (open.length) { | ||
do_blocks = true; | ||
for (key in blocks) { | ||
if (!block_indexes) { | ||
block_indexes = {}; | ||
block_indexes_arr = []; | ||
} | ||
if (state === key) { | ||
close = blocks[key][1]; | ||
for (i = 0; i < open.length; i++) { | ||
block_indexes[open[i]] = key; | ||
block_indexes_arr.push(open[i]); | ||
} | ||
} | ||
} | ||
if (char === close[0] && source[i+1] == close[1] && source.substr(i, close.length) == close) { | ||
current.value += close; | ||
current = null; | ||
i += close.length - 1; | ||
state = prev_state || STATE_PLAINTEXT; | ||
prev_state = null; | ||
do_continue = true; | ||
break; | ||
} | ||
if (do_blocks) { | ||
Bound.Array.flashsort(block_indexes_arr); | ||
block_indexes_arr = Bound.Array.unique(block_indexes_arr); | ||
} | ||
} | ||
current.value += char; | ||
do_continue = true; | ||
break; | ||
} | ||
for (i = 0; i < length; i++) { | ||
char = source[i]; | ||
open = blocks[key][0]; | ||
if (do_blocks && (key = block_indexes[i])) { | ||
block = blocks[key]; | ||
if (char === open[0] && source[i+1] == open[1] && source.substr(i, open.length) == open) { | ||
prev_state = state; | ||
state = key; | ||
if (block.forbidden && block.forbidden[state]) { | ||
throw new Error('Unexpected ' + key + ' block at char ' + i); | ||
} | ||
current = { | ||
type : key, | ||
value : open | ||
}; | ||
// Remove this index from the array | ||
block_indexes_arr.shift(); | ||
i += open.length - 1; | ||
current = null; | ||
end = source.indexOf(block.close, i); | ||
result.push(current); | ||
do_continue = true; | ||
break; | ||
} | ||
if (end == -1) { | ||
end = source.length; | ||
} else { | ||
end += block.close.length; | ||
} | ||
if (do_continue) { | ||
continue; | ||
result.push({ | ||
type : key, | ||
value : source.slice(i, end) | ||
}); | ||
if (state === STATE.ATTR_VAL) { | ||
state = STATE.TAG_CONTENT; | ||
} | ||
i = end - 1; | ||
continue; | ||
} | ||
if (state === STATE_SCRIPT) { | ||
if (state === STATE.SCRIPT) { | ||
if (!current) { | ||
@@ -711,3 +727,3 @@ current = { | ||
if (source.substr(i+1, 7) == '/script') { | ||
state = STATE_PLAINTEXT; | ||
state = STATE.PLAINTEXT; | ||
tag_buffer = ''; | ||
@@ -719,3 +735,3 @@ closing = true; | ||
// Is the state still script? | ||
if (state === STATE_SCRIPT) { | ||
if (state === STATE.SCRIPT) { | ||
current.value += char; | ||
@@ -726,3 +742,3 @@ continue; | ||
if (state === STATE_COMMENT) { | ||
if (state === STATE.COMMENT) { | ||
if (char == '-' && source.substr(i, 3) == '-->') { | ||
@@ -732,3 +748,3 @@ current.value += '-->'; | ||
i += 2; | ||
state = STATE_PLAINTEXT; | ||
state = STATE.PLAINTEXT; | ||
continue; | ||
@@ -741,8 +757,8 @@ } | ||
if (state === STATE_ATTR_VAL) { | ||
if (state === STATE.ATTR_VAL) { | ||
if (!char.trim()) { | ||
state = STATE_TAG_CONTENT; | ||
state = STATE.TAG_CONTENT; | ||
current = null; | ||
} else if (char == '"') { | ||
state = STATE_STRING_D; | ||
state = STATE.STRING_D; | ||
current = { | ||
@@ -755,3 +771,3 @@ type : 'string', | ||
} else if (char == "'") { | ||
state = STATE_STRING_S; | ||
state = STATE.STRING_S; | ||
current = { | ||
@@ -764,3 +780,3 @@ type : 'string', | ||
} else { | ||
state = STATE_ATTR_IDENT; | ||
state = STATE.ATTR_IDENT; | ||
current = { | ||
@@ -777,3 +793,3 @@ type : 'identifier', | ||
if (state === STATE_STRING_D) { | ||
if (state === STATE.STRING_D) { | ||
@@ -788,3 +804,3 @@ if (char == '<' || char == '>') { | ||
current = null; | ||
state = STATE_TAG_CONTENT; | ||
state = STATE.TAG_CONTENT; | ||
} | ||
@@ -795,3 +811,3 @@ | ||
if (state === STATE_STRING_S) { | ||
if (state === STATE.STRING_S) { | ||
@@ -806,3 +822,3 @@ if (char == '<' || char == '>') { | ||
current = null; | ||
state = STATE_TAG_CONTENT; | ||
state = STATE.TAG_CONTENT; | ||
} | ||
@@ -813,6 +829,6 @@ | ||
if (state === STATE_ATTR_IDENT) { | ||
if (state === STATE.ATTR_IDENT) { | ||
if (!char.trim()) { | ||
state = STATE_TAG_CONTENT; | ||
state = STATE.TAG_CONTENT; | ||
current = null; | ||
@@ -827,7 +843,7 @@ i--; | ||
if (state === STATE_PLAINTEXT) { | ||
if (state === STATE.PLAINTEXT) { | ||
if (char == '<' && source[i + 1] && source[i + 1].trim()) { | ||
if (source.substr(i, 4) == '<!--') { | ||
state = STATE_COMMENT; | ||
state = STATE.COMMENT; | ||
current = {type: 'comment', value: char}; | ||
@@ -839,3 +855,3 @@ result.push(current); | ||
state = STATE_HTML; | ||
state = STATE.HTML; | ||
tag_buffer += char; | ||
@@ -864,3 +880,21 @@ result.push({type: 'open_bracket', value: '<'}); | ||
current.value += char; | ||
// Anything until the next bracket is plain text! | ||
end = source.indexOf('<', i + 1); | ||
if (end == -1) { | ||
end = source.length; | ||
} | ||
// If there are custom block definitions (and there are | ||
// still custom blocks coming up) then don't include these | ||
// as plain text! | ||
if (do_blocks && block_indexes_arr.length) { | ||
if (block_indexes_arr[0] < end) { | ||
end = block_indexes_arr[0]; | ||
} | ||
} | ||
//current.value += char; | ||
current.value += source.slice(i, end); | ||
i = end - 1; | ||
} | ||
@@ -871,7 +905,7 @@ | ||
if (state === STATE_COMMENT) { | ||
if (state === STATE.COMMENT) { | ||
if (char == '>') { | ||
if (tag_buffer.slice(-2) == '--') { | ||
// Close the comment | ||
state = STATE_PLAINTEXT; | ||
state = STATE.PLAINTEXT; | ||
current = null; | ||
@@ -889,3 +923,3 @@ } | ||
if (state === STATE_TAG_NAME || state === STATE_TAG_CONTENT) { | ||
if (state === STATE.TAG_NAME || state === STATE.TAG_CONTENT) { | ||
if (!char.trim()) { | ||
@@ -899,4 +933,4 @@ if (!current || current.type != 'whitespace') { | ||
if (state === STATE_TAG_NAME) { | ||
state = STATE_TAG_CONTENT; | ||
if (state === STATE.TAG_NAME) { | ||
state = STATE.TAG_CONTENT; | ||
} | ||
@@ -917,5 +951,5 @@ } else { | ||
if (!closing && last_tag.toLowerCase() == 'script') { | ||
state = STATE_SCRIPT; | ||
state = STATE.SCRIPT; | ||
} else { | ||
state = STATE_PLAINTEXT; | ||
state = STATE.PLAINTEXT; | ||
} | ||
@@ -926,3 +960,3 @@ | ||
depth++; | ||
} else if (state === STATE_TAG_NAME) { | ||
} else if (state === STATE.TAG_NAME) { | ||
current.value += char; | ||
@@ -938,11 +972,9 @@ last_tag += char; | ||
state = STATE_ATTR_NAME; | ||
current = { | ||
type : 'attribute', | ||
value : char | ||
}; | ||
state = STATE.ATTR_NAME; | ||
current = { | ||
type : 'attribute', | ||
value : char | ||
}; | ||
result.push(current); | ||
result.push(current); | ||
} | ||
@@ -953,6 +985,6 @@ | ||
if (state === STATE_ATTR_NAME && !depth) { | ||
if (state === STATE.ATTR_NAME && !depth) { | ||
if (!char.trim() || char == '>') { | ||
i--; | ||
state = STATE_TAG_CONTENT; | ||
state = STATE.TAG_CONTENT; | ||
continue; | ||
@@ -963,3 +995,3 @@ } | ||
result.push({type: 'equals', value: '='}); | ||
state = STATE_ATTR_VAL; | ||
state = STATE.ATTR_VAL; | ||
continue; | ||
@@ -976,6 +1008,6 @@ } | ||
if (char == '!' && source.substr(i, 2) == '!-') { | ||
state = STATE_COMMENT; | ||
state = STATE.COMMENT; | ||
current = {type: 'comment', value: char}; | ||
} else { | ||
state = STATE_TAG_NAME; | ||
state = STATE.TAG_NAME; | ||
last_tag = char; | ||
@@ -1059,3 +1091,3 @@ current = {type: 'tag_name', value: char}; | ||
if (state == STATE_HTML) { | ||
if (state == STATE.HTML) { | ||
buf += token.value; | ||
@@ -1092,3 +1124,3 @@ | ||
} else if (token.type == 'open_bracket') { | ||
state = STATE_HTML; | ||
state = STATE.HTML; | ||
buf = token.value; | ||
@@ -1491,2 +1523,25 @@ } else { | ||
/** | ||
* Get all indexes of the given needle | ||
* | ||
* @author Jelle De Loecker <jelle@develry.be> | ||
* @since 0.6.6 | ||
* @version 0.6.6 | ||
* | ||
* @param {String} needle | ||
* | ||
* @return {Array} All the indexes | ||
*/ | ||
Blast.definePrototype('String', function allIndexesOf(needle) { | ||
var result = [], | ||
i = -1; | ||
while ((i = this.indexOf(needle, i + 1)) != -1) { | ||
result.push(i); | ||
} | ||
return result; | ||
}); | ||
/** | ||
* See if a string starts with the given word | ||
@@ -1493,0 +1548,0 @@ * |
{ | ||
"name": "protoblast", | ||
"description": "Native object expansion library", | ||
"version": "0.6.5", | ||
"version": "0.6.6", | ||
"author": "Jelle De Loecker <jelle@develry.be>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
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
616459
51
25162