.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / postcss-media-query-parser / dist / nodes / Container.js
diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/postcss-media-query-parser/dist/nodes/Container.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/postcss-media-query-parser/dist/nodes/Container.js
new file mode 100644 (file)
index 0000000..9c81a0a
--- /dev/null
@@ -0,0 +1,94 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+
+var _Node = require('./Node');
+
+var _Node2 = _interopRequireDefault(_Node);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function Container(opts) {
+  var _this = this;
+
+  this.constructor(opts);
+
+  this.nodes = opts.nodes;
+
+  if (this.after === undefined) {
+    this.after = this.nodes.length > 0 ? this.nodes[this.nodes.length - 1].after : '';
+  }
+
+  if (this.before === undefined) {
+    this.before = this.nodes.length > 0 ? this.nodes[0].before : '';
+  }
+
+  if (this.sourceIndex === undefined) {
+    this.sourceIndex = this.before.length;
+  }
+
+  this.nodes.forEach(function (node) {
+    node.parent = _this; // eslint-disable-line no-param-reassign
+  });
+} /**\r
+   * A node that contains other nodes and support traversing over them\r
+   */
+
+Container.prototype = Object.create(_Node2.default.prototype);
+Container.constructor = _Node2.default;
+
+/**\r
+ * Iterate over descendant nodes of the node\r
+ *\r
+ * @param {RegExp|string} filter - Optional. Only nodes with node.type that\r
+ *    satisfies the filter will be traversed over\r
+ * @param {function} cb - callback to call on each node. Takes theese params:\r
+ *    node - the node being processed, i - it's index, nodes - the array\r
+ *    of all nodes\r
+ *    If false is returned, the iteration breaks\r
+ *\r
+ * @return (boolean) false, if the iteration was broken\r
+ */
+Container.prototype.walk = function walk(filter, cb) {
+  var hasFilter = typeof filter === 'string' || filter instanceof RegExp;
+  var callback = hasFilter ? cb : filter;
+  var filterReg = typeof filter === 'string' ? new RegExp(filter) : filter;
+
+  for (var i = 0; i < this.nodes.length; i++) {
+    var node = this.nodes[i];
+    var filtered = hasFilter ? filterReg.test(node.type) : true;
+    if (filtered && callback && callback(node, i, this.nodes) === false) {
+      return false;
+    }
+    if (node.nodes && node.walk(filter, cb) === false) {
+      return false;
+    }
+  }
+  return true;
+};
+
+/**\r
+ * Iterate over immediate children of the node\r
+ *\r
+ * @param {function} cb - callback to call on each node. Takes theese params:\r
+ *    node - the node being processed, i - it's index, nodes - the array\r
+ *    of all nodes\r
+ *    If false is returned, the iteration breaks\r
+ *\r
+ * @return (boolean) false, if the iteration was broken\r
+ */
+Container.prototype.each = function each() {
+  var cb = arguments.length <= 0 || arguments[0] === undefined ? function () {} : arguments[0];
+
+  for (var i = 0; i < this.nodes.length; i++) {
+    var node = this.nodes[i];
+    if (cb(node, i, this.nodes) === false) {
+      return false;
+    }
+  }
+  return true;
+};
+
+exports.default = Container;
\ No newline at end of file