Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

transformers

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

transformers - npm Package Compare versions

Comparing version 1.8.0 to 1.8.1

.travis.yml

6

history.md

@@ -0,1 +1,7 @@

## 1.8.1 - 2013-02-10
- Add travis-ci
- FIX **toffee** support which was broken by their latest update
- FIX lookup paths for **component** weren't set so you couldn't build components with dependancies
## 1.8.0 - 2013-01-30

@@ -2,0 +8,0 @@

18

lib/transformers.js

@@ -193,3 +193,3 @@ var dirname = require('path').dirname;

var v = this.cache(options) || this.cache(options, new View(str, options));
var res = v.run(options);
var res = v.run(options, require('vm').createContext({}));
if (res[0]) throw res[0];

@@ -473,2 +473,10 @@ else return res[1];

}
var path = require('path');
builder.paths = (options.paths || ['components']).map(function (p) {
if (path.resolve(p) === p) {
return p;
} else {
return path.join(dirname(options.filename), p);
}
});
builder.build(function (err, obj) {

@@ -492,2 +500,10 @@ if (err) return cb(err);

}
var path = require('path');
builder.paths = (options.paths || ['components']).map(function (p) {
if (path.resolve(p) === p) {
return p;
} else {
return path.join(dirname(options.filename), p);
}
});
builder.build(function (err, obj) {

@@ -494,0 +510,0 @@ if (err) return cb(err);

5

package.json
{
"name": "transformers",
"version": "1.8.0",
"version": "1.8.1",
"description": "String/Data transformations for use in templating libraries, static site generators and web frameworks",

@@ -65,3 +65,4 @@ "main": "lib/transformers.js",

"component-builder": "*",
"html2jade": "0.0.7"
"html2jade": "*",
"highlight.js": "*"
},

@@ -68,0 +69,0 @@ "dependencies": {

@@ -0,1 +1,2 @@

[![Build Status](https://travis-ci.org/ForbesLindesay/transformers.png?branch=master)](https://travis-ci.org/ForbesLindesay/transformers)
# transformers

@@ -56,3 +57,3 @@

- [component-css](http://documentup.com/component/component) [(website)](http://component.io) - `npm install component-builder` options: `{development: false}`
- [html2jade](http://documentup.com/donpark/html2jade) [(website)](http://html2jade.aaron-powell.com/) - `npm install html2jade@0.0.7` note that later versions have a bug that means they won't work (this will be fixed by [pull/48](https://github.com/donpark/html2jade/pull/48))
- [html2jade](http://documentup.com/donpark/html2jade) [(website)](http://html2jade.aaron-powell.com/) - `npm install html2jade` - Converts HTML back into jade

@@ -59,0 +60,0 @@ Pull requests to add more transforms will always be accepted providing they are open-source, come with unit tests, and don't cause any of the tests to fail.

@@ -72,2 +72,3 @@

require.resolve = function(path) {
if (path.charAt(0) === '/') path = path.slice(1);
var index = path + '/index.js';

@@ -185,13 +186,14 @@

localRequire.resolve = function(path) {
var c = path.charAt(0);
if ('/' == c) return path.slice(1);
if ('.' == c) return require.normalize(p, path);
// resolve deps by returning
// the dep in the nearest "deps"
// directory
if ('.' != path.charAt(0)) {
var segs = parent.split('/');
var i = lastIndexOf(segs, 'deps') + 1;
if (!i) i = 0;
path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
return path;
}
return require.normalize(p, path);
var segs = parent.split('/');
var i = lastIndexOf(segs, 'deps') + 1;
if (!i) i = 0;
path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
return path;
};

@@ -209,5 +211,1028 @@

};
require.register("component-type/index.js", function(exports, require, module){
/**
* toString ref.
*/
var toString = Object.prototype.toString;
/**
* Return the type of `val`.
*
* @param {Mixed} val
* @return {String}
* @api public
*/
module.exports = function(val){
switch (toString.call(val)) {
case '[object Function]': return 'function';
case '[object Date]': return 'date';
case '[object RegExp]': return 'regexp';
case '[object Arguments]': return 'arguments';
case '[object Array]': return 'array';
case '[object String]': return 'string';
}
if (val === null) return 'null';
if (val === undefined) return 'undefined';
if (val === Object(val)) return 'object';
return typeof val;
};
});
require.register("component-event/index.js", function(exports, require, module){
/**
* Bind `el` event `type` to `fn`.
*
* @param {Element} el
* @param {String} type
* @param {Function} fn
* @param {Boolean} capture
* @return {Function}
* @api public
*/
exports.bind = function(el, type, fn, capture){
if (el.addEventListener) {
el.addEventListener(type, fn, capture);
} else {
el.attachEvent('on' + type, fn);
}
return fn;
};
/**
* Unbind `el` event `type`'s callback `fn`.
*
* @param {Element} el
* @param {String} type
* @param {Function} fn
* @param {Boolean} capture
* @return {Function}
* @api public
*/
exports.unbind = function(el, type, fn, capture){
if (el.removeEventListener) {
el.removeEventListener(type, fn, capture);
} else {
el.detachEvent('on' + type, fn);
}
return fn;
};
});
require.register("component-matches-selector/index.js", function(exports, require, module){
/**
* Element prototype.
*/
var proto = Element.prototype;
/**
* Vendor function.
*/
var vendor = proto.matchesSelector
|| proto.webkitMatchesSelector
|| proto.mozMatchesSelector
|| proto.msMatchesSelector
|| proto.oMatchesSelector;
/**
* Expose `match()`.
*/
module.exports = match;
/**
* Match `el` to `selector`.
*
* @param {Element} el
* @param {String} selector
* @return {Boolean}
* @api public
*/
function match(el, selector) {
if (vendor) return vendor.call(el, selector);
var nodes = el.parentNode.querySelectorAll(selector);
for (var i = 0; i < nodes.length; ++i) {
if (nodes[i] == el) return true;
}
return false;
}
});
require.register("component-delegate/index.js", function(exports, require, module){
/**
* Module dependencies.
*/
var matches = require('matches-selector')
, event = require('event');
/**
* Delegate event `type` to `selector`
* and invoke `fn(e)`. A callback function
* is returned which may be passed to `.unbind()`.
*
* @param {Element} el
* @param {String} selector
* @param {String} type
* @param {Function} fn
* @param {Boolean} capture
* @return {Function}
* @api public
*/
exports.bind = function(el, selector, type, fn, capture){
return event.bind(el, type, function(e){
if (matches(e.target, selector)) fn(e);
}, capture);
return callback;
};
/**
* Unbind event `type`'s callback `fn`.
*
* @param {Element} el
* @param {String} type
* @param {Function} fn
* @param {Boolean} capture
* @api public
*/
exports.unbind = function(el, type, fn, capture){
event.unbind(el, type, fn, capture);
};
});
require.register("component-indexof/index.js", function(exports, require, module){
var indexOf = [].indexOf;
module.exports = function(arr, obj){
if (indexOf) return arr.indexOf(obj);
for (var i = 0; i < arr.length; ++i) {
if (arr[i] === obj) return i;
}
return -1;
};
});
require.register("component-domify/index.js", function(exports, require, module){
/**
* Expose `parse`.
*/
module.exports = parse;
/**
* Wrap map from jquery.
*/
var map = {
option: [1, '<select multiple="multiple">', '</select>'],
optgroup: [1, '<select multiple="multiple">', '</select>'],
legend: [1, '<fieldset>', '</fieldset>'],
thead: [1, '<table>', '</table>'],
tbody: [1, '<table>', '</table>'],
tfoot: [1, '<table>', '</table>'],
colgroup: [1, '<table>', '</table>'],
caption: [1, '<table>', '</table>'],
tr: [2, '<table><tbody>', '</tbody></table>'],
td: [3, '<table><tbody><tr>', '</tr></tbody></table>'],
th: [3, '<table><tbody><tr>', '</tr></tbody></table>'],
col: [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
_default: [0, '', '']
};
/**
* Parse `html` and return the children.
*
* @param {String} html
* @return {Array}
* @api private
*/
function parse(html) {
if ('string' != typeof html) throw new TypeError('String expected');
// tag name
var m = /<([\w:]+)/.exec(html);
if (!m) throw new Error('No elements were generated.');
var tag = m[1];
// body support
if (tag == 'body') {
var el = document.createElement('html');
el.innerHTML = html;
return [el.removeChild(el.lastChild)];
}
// wrap map
var wrap = map[tag] || map._default;
var depth = wrap[0];
var prefix = wrap[1];
var suffix = wrap[2];
var el = document.createElement('div');
el.innerHTML = prefix + html + suffix;
while (depth--) el = el.lastChild;
return orphan(el.children);
}
/**
* Orphan `els` and return an array.
*
* @param {NodeList} els
* @return {Array}
* @api private
*/
function orphan(els) {
var ret = [];
while (els.length) {
ret.push(els[0].parentNode.removeChild(els[0]));
}
return ret;
}
});
require.register("component-classes/index.js", function(exports, require, module){
/**
* Module dependencies.
*/
var index = require('indexof');
/**
* Whitespace regexp.
*/
var re = /\s+/;
/**
* toString reference.
*/
var toString = Object.prototype.toString;
/**
* Wrap `el` in a `ClassList`.
*
* @param {Element} el
* @return {ClassList}
* @api public
*/
module.exports = function(el){
return new ClassList(el);
};
/**
* Initialize a new ClassList for `el`.
*
* @param {Element} el
* @api private
*/
function ClassList(el) {
this.el = el;
this.list = el.classList;
}
/**
* Add class `name` if not already present.
*
* @param {String} name
* @return {ClassList}
* @api public
*/
ClassList.prototype.add = function(name){
// classList
if (this.list) {
this.list.add(name);
return this;
}
// fallback
var arr = this.array();
var i = index(arr, name);
if (!~i) arr.push(name);
this.el.className = arr.join(' ');
return this;
};
/**
* Remove class `name` when present, or
* pass a regular expression to remove
* any which match.
*
* @param {String|RegExp} name
* @return {ClassList}
* @api public
*/
ClassList.prototype.remove = function(name){
if ('[object RegExp]' == toString.call(name)) {
return this.removeMatching(name);
}
// classList
if (this.list) {
this.list.remove(name);
return this;
}
// fallback
var arr = this.array();
var i = index(arr, name);
if (~i) arr.splice(i, 1);
this.el.className = arr.join(' ');
return this;
};
/**
* Remove all classes matching `re`.
*
* @param {RegExp} re
* @return {ClassList}
* @api private
*/
ClassList.prototype.removeMatching = function(re){
var arr = this.array();
for (var i = 0; i < arr.length; i++) {
if (re.test(arr[i])) {
this.remove(arr[i]);
}
}
return this;
};
/**
* Toggle class `name`.
*
* @param {String} name
* @return {ClassList}
* @api public
*/
ClassList.prototype.toggle = function(name){
// classList
if (this.list) {
this.list.toggle(name);
return this;
}
// fallback
if (this.has(name)) {
this.remove(name);
} else {
this.add(name);
}
return this;
};
/**
* Return an array of classes.
*
* @return {Array}
* @api public
*/
ClassList.prototype.array = function(){
var arr = this.el.className.split(re);
if ('' === arr[0]) arr.pop();
return arr;
};
/**
* Check if class `name` is present.
*
* @param {String} name
* @return {ClassList}
* @api public
*/
ClassList.prototype.has =
ClassList.prototype.contains = function(name){
return this.list
? this.list.contains(name)
: !! ~index(this.array(), name);
};
});
require.register("component-dom/index.js", function(exports, require, module){
/**
* Module dependencies.
*/
var domify = require('domify')
, classes = require('classes')
, indexof = require('indexof')
, delegate = require('delegate')
, events = require('event')
, type = require('type')
/**
* Attributes supported.
*/
var attrs = [
'id',
'src',
'rel',
'cols',
'rows',
'name',
'href',
'title',
'style',
'width',
'height',
'tabindex',
'placeholder'
];
/**
* Expose `dom()`.
*/
exports = module.exports = dom;
/**
* Expose supported attrs.
*/
exports.attrs = attrs;
/**
* Return a dom `List` for the given
* `html`, selector, or element.
*
* @param {String|Element|List}
* @return {List}
* @api public
*/
function dom(selector, context) {
var ctx = context
? (context.els ? context.els[0] : context)
: document.firstChild;
// array
if (Array.isArray(selector)) {
return new List(selector);
}
// List
if (selector instanceof List) {
return selector;
}
// node
if (selector.nodeName) {
return new List([selector]);
}
// html
if ('<' == selector.charAt(0)) {
return new List([domify(selector)[0]], selector);
}
// selector
if ('string' == typeof selector) {
return new List(ctx.querySelectorAll(selector), selector);
}
}
/**
* Expose `List` constructor.
*/
exports.List = List;
/**
* Initialize a new `List` with the
* given array-ish of `els` and `selector`
* string.
*
* @param {Mixed} els
* @param {String} selector
* @api private
*/
function List(els, selector) {
this.els = els || [];
this.selector = selector;
}
/**
* Set attribute `name` to `val`, or get attr `name`.
*
* @param {String} name
* @param {String} [val]
* @return {String|List} self
* @api public
*/
List.prototype.attr = function(name, val){
if (2 == arguments.length) {
this.els[0].setAttribute(name, val);
return this;
} else {
return this.els[0].getAttribute(name);
}
};
/**
* Return a cloned `List` with all elements cloned.
*
* @return {List}
* @api public
*/
List.prototype.clone = function(){
var arr = [];
for (var i = 0, len = this.els.length; i < len; ++i) {
arr.push(this.els[i].cloneNode(true));
}
return new List(arr);
};
/**
* Prepend `val`.
*
* @param {String|Element|List} val
* @return {List} self
* @api public
*/
List.prototype.prepend = function(val){
var el = this.els[0];
if (!el) return this;
val = dom(val);
for (var i = 0; i < val.els.length; ++i) {
if (el.children.length) {
el.insertBefore(val.els[i], el.firstChild);
} else {
el.appendChild(val.els[i]);
}
}
return this;
};
/**
* Append `val`.
*
* @param {String|Element|List} val
* @return {List} self
* @api public
*/
List.prototype.append = function(val){
var el = this.els[0];
if (!el) return this;
val = dom(val);
for (var i = 0; i < val.els.length; ++i) {
el.appendChild(val.els[i]);
}
return this;
};
/**
* Append self's `el` to `val`
*
* @param {String|Element|List} val
* @return {List} self
* @api public
*/
List.prototype.appendTo = function(val){
dom(val).append(this);
};
/**
* Return a `List` containing the element at `i`.
*
* @param {Number} i
* @return {List}
* @api public
*/
List.prototype.at = function(i){
return new List([this.els[i]], this.selector);
};
/**
* Return a `List` containing the first element.
*
* @param {Number} i
* @return {List}
* @api public
*/
List.prototype.first = function(){
return new List([this.els[0]], this.selector);
};
/**
* Return a `List` containing the last element.
*
* @param {Number} i
* @return {List}
* @api public
*/
List.prototype.last = function(){
return new List([this.els[this.els.length - 1]], this.selector);
};
/**
* Return an `Element` at `i`.
*
* @param {Number} i
* @return {Element}
* @api public
*/
List.prototype.get = function(i){
return this.els[i];
};
/**
* Return list length.
*
* @return {Number}
* @api public
*/
List.prototype.length = function(){
return this.els.length;
};
/**
* Return element text.
*
* @return {String}
* @api public
*/
List.prototype.text = function(){
// TODO: real impl
var str = '';
for (var i = 0; i < this.els.length; ++i) {
str += this.els[i].textContent;
}
return str;
};
/**
* Return element html.
*
* @return {String}
* @api public
*/
List.prototype.html = function(){
// TODO: real impl
return this.els[0] && this.els[0].innerHTML;
};
/**
* Bind to `event` and invoke `fn(e)`. When
* a `selector` is given then events are delegated.
*
* @param {String} event
* @param {String} [selector]
* @param {Function} fn
* @param {Boolean} capture
* @return {List}
* @api public
*/
List.prototype.on = function(event, selector, fn, capture){
if ('string' == typeof selector) {
for (var i = 0; i < this.els.length; ++i) {
fn._delegate = delegate.bind(this.els[i], selector, event, fn, capture);
}
return this;
}
capture = fn;
fn = selector;
for (var i = 0; i < this.els.length; ++i) {
events.bind(this.els[i], event, fn, capture);
}
return this;
};
/**
* Unbind to `event` and invoke `fn(e)`. When
* a `selector` is given then delegated event
* handlers are unbound.
*
* @param {String} event
* @param {String} [selector]
* @param {Function} fn
* @param {Boolean} capture
* @return {List}
* @api public
*/
List.prototype.off = function(event, selector, fn, capture){
if ('string' == typeof selector) {
for (var i = 0; i < this.els.length; ++i) {
// TODO: add selector support back
delegate.unbind(this.els[i], event, fn._delegate, capture);
}
return this;
}
capture = fn;
fn = selector;
for (var i = 0; i < this.els.length; ++i) {
events.unbind(this.els[i], event, fn, capture);
}
return this;
};
/**
* Iterate elements and invoke `fn(list, i)`.
*
* @param {Function} fn
* @return {List} self
* @api public
*/
List.prototype.each = function(fn){
for (var i = 0; i < this.els.length; ++i) {
fn(new List([this.els[i]], this.selector), i);
}
return this;
};
/**
* Iterate elements and invoke `fn(el, i)`.
*
* @param {Function} fn
* @return {List} self
* @api public
*/
List.prototype.forEach = function(fn){
for (var i = 0; i < this.els.length; ++i) {
fn(this.els[i], i);
}
return this;
};
/**
* Map elements invoking `fn(list, i)`.
*
* @param {Function} fn
* @return {Array}
* @api public
*/
List.prototype.map = function(fn){
var arr = [];
for (var i = 0; i < this.els.length; ++i) {
arr.push(fn(new List([this.els[i]], this.selector), i));
}
return arr;
};
/**
* Filter elements invoking `fn(list, i)`, returning
* a new `List` of elements when a truthy value is returned.
*
* @param {Function} fn
* @return {List}
* @api public
*/
List.prototype.select =
List.prototype.filter = function(fn){
var el;
var list = new List([], this.selector);
for (var i = 0; i < this.els.length; ++i) {
el = this.els[i];
if (fn(new List([el], this.selector), i)) list.els.push(el);
}
return list;
};
/**
* Add the given class `name`.
*
* @param {String} name
* @return {List} self
* @api public
*/
List.prototype.addClass = function(name){
var el;
for (var i = 0; i < this.els.length; ++i) {
el = this.els[i];
el._classes = el._classes || classes(el);
el._classes.add(name);
}
return this;
};
/**
* Remove the given class `name`.
*
* @param {String|RegExp} name
* @return {List} self
* @api public
*/
List.prototype.removeClass = function(name){
var el;
if ('regexp' == type(name)) {
for (var i = 0; i < this.els.length; ++i) {
el = this.els[i];
el._classes = el._classes || classes(el);
var arr = el._classes.array();
for (var j = 0; j < arr.length; j++) {
if (name.test(arr[j])) {
el._classes.remove(arr[j]);
}
}
}
return this;
}
for (var i = 0; i < this.els.length; ++i) {
el = this.els[i];
el._classes = el._classes || classes(el);
el._classes.remove(name);
}
return this;
};
/**
* Toggle the given class `name`,
* optionally a `bool` may be given
* to indicate that the class should
* be added when truthy.
*
* @param {String} name
* @param {Boolean} bool
* @return {List} self
* @api public
*/
List.prototype.toggleClass = function(name, bool){
var el;
var fn = 'toggle';
// toggle with boolean
if (2 == arguments.length) {
fn = bool ? 'add' : 'remove';
}
for (var i = 0; i < this.els.length; ++i) {
el = this.els[i];
el._classes = el._classes || classes(el);
el._classes[fn](name);
}
return this;
};
/**
* Check if the given class `name` is present.
*
* @param {String} name
* @return {Boolean}
* @api public
*/
List.prototype.hasClass = function(name){
var el;
for (var i = 0; i < this.els.length; ++i) {
el = this.els[i];
el._classes = el._classes || classes(el);
if (el._classes.has(name)) return true;
}
return false;
};
/**
* Set CSS `prop` to `val` or get `prop` value.
*
* @param {String} prop
* @param {Mixed} val
* @return {List|String}
* @api public
*/
List.prototype.css = function(prop, val){
if (2 == arguments.length) return this.setStyle(prop, val);
return this.getStyle(prop);
};
/**
* Set CSS `prop` to `val`.
*
* @param {String} prop
* @param {Mixed} val
* @return {List} self
* @api private
*/
List.prototype.setStyle = function(prop, val){
for (var i = 0; i < this.els.length; ++i) {
this.els[i].style[prop] = val;
}
return this;
};
/**
* Get CSS `prop` value.
*
* @param {String} prop
* @return {String}
* @api private
*/
List.prototype.getStyle = function(prop){
var el = this.els[0];
if (el) return el.style[prop];
};
/**
* Find children matching the given `selector`.
*
* @param {String} selector
* @return {List}
* @api public
*/
List.prototype.find = function(selector){
// TODO: real implementation
var list = new List([], this.selector);
var el, els;
for (var i = 0; i < this.els.length; ++i) {
el = this.els[i];
els = el.querySelectorAll(selector);
for (var j = 0; j < els.length; ++j) {
list.els.push(els[j]);
}
}
return list;
};
/**
* Attribute accessors.
*/
attrs.forEach(function(name){
List.prototype[name] = function(val){
if (0 == arguments.length) return this.attr(name);
return this.attr(name, val);
};
});
});
require.register("foo/index.js", function(exports, require, module){
module.exports = 'foo';
});
require.alias("component-dom/index.js", "foo/deps/dom/index.js");
require.alias("component-type/index.js", "component-dom/deps/type/index.js");
require.alias("component-event/index.js", "component-dom/deps/event/index.js");
require.alias("component-delegate/index.js", "component-dom/deps/delegate/index.js");
require.alias("component-matches-selector/index.js", "component-delegate/deps/matches-selector/index.js");
require.alias("component-event/index.js", "component-delegate/deps/event/index.js");
require.alias("component-indexof/index.js", "component-dom/deps/indexof/index.js");
require.alias("component-domify/index.js", "component-dom/deps/domify/index.js");
require.alias("component-classes/index.js", "component-dom/deps/classes/index.js");
require.alias("component-indexof/index.js", "component-classes/deps/indexof/index.js");
{
"name": "foo",
"scripts": ["index.js"],
"styles": ["index.css", "second.css"]
"styles": ["index.css", "second.css"],
"dependencies": {
"component/dom": "*"
}
}

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