package.json 11.3 KB
{
  "_args": [
    [
      {
        "raw": "postcss-value-parser@^3.2.3",
        "scope": null,
        "escapedName": "postcss-value-parser",
        "name": "postcss-value-parser",
        "rawSpec": "^3.2.3",
        "spec": ">=3.2.3 <4.0.0",
        "type": "range"
      },
      "D:\\100-Projects\\100-AIAHTML5\\400-SOURCECODE\\AIAHTML5.Admin\\node_modules\\autoprefixer"
    ]
  ],
  "_from": "postcss-value-parser@>=3.2.3 <4.0.0",
  "_id": "postcss-value-parser@3.3.0",
  "_inCache": true,
  "_location": "/postcss-value-parser",
  "_nodeVersion": "0.12.7",
  "_npmOperationalInternal": {
    "host": "packages-6-west.internal.npmjs.com",
    "tmp": "tmp/postcss-value-parser-3.3.0.tgz_1455817254522_0.1339812579099089"
  },
  "_npmUser": {
    "name": "trysound",
    "email": "trysound@yandex.ru"
  },
  "_npmVersion": "3.7.2",
  "_phantomChildren": {},
  "_requested": {
    "raw": "postcss-value-parser@^3.2.3",
    "scope": null,
    "escapedName": "postcss-value-parser",
    "name": "postcss-value-parser",
    "rawSpec": "^3.2.3",
    "spec": ">=3.2.3 <4.0.0",
    "type": "range"
  },
  "_requiredBy": [
    "/autoprefixer",
    "/css-loader",
    "/cssnano",
    "/postcss-colormin",
    "/postcss-convert-values",
    "/postcss-merge-idents",
    "/postcss-minify-font-values",
    "/postcss-minify-gradients",
    "/postcss-minify-params",
    "/postcss-normalize-url",
    "/postcss-ordered-values",
    "/postcss-reduce-idents",
    "/postcss-reduce-transforms",
    "/postcss-svgo"
  ],
  "_resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.0.tgz",
  "_shasum": "87f38f9f18f774a4ab4c8a232f5c5ce8872a9d15",
  "_shrinkwrap": null,
  "_spec": "postcss-value-parser@^3.2.3",
  "_where": "D:\\100-Projects\\100-AIAHTML5\\400-SOURCECODE\\AIAHTML5.Admin\\node_modules\\autoprefixer",
  "author": {
    "name": "Bogdan Chadkin",
    "email": "trysound@yandex.ru"
  },
  "bugs": {
    "url": "https://github.com/TrySound/postcss-value-parser/issues"
  },
  "dependencies": {},
  "description": "Transforms css values and at-rule params into the tree",
  "devDependencies": {
    "eslint": "^2.1.0",
    "eslint-config-postcss": "^2.0.0",
    "tap-spec": "^4.1.0",
    "tape": "^4.2.0"
  },
  "directories": {},
  "dist": {
    "shasum": "87f38f9f18f774a4ab4c8a232f5c5ce8872a9d15",
    "tarball": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.0.tgz"
  },
  "eslintConfig": {
    "extends": "postcss/es5",
    "rules": {
      "max-len": 0,
      "no-bitwise": 0,
      "complexity": 0,
      "no-use-before-define": 0,
      "consistent-return": 0
    }
  },
  "files": [
    "lib"
  ],
  "gitHead": "c2738fbc73bf1162481862ddce7d011cc0a57b15",
  "homepage": "https://github.com/TrySound/postcss-value-parser",
  "keywords": [
    "postcss",
    "value",
    "parser"
  ],
  "license": "MIT",
  "main": "lib/index.js",
  "maintainers": [
    {
      "name": "trysound",
      "email": "trysound@yandex.ru"
    },
    {
      "name": "beneb",
      "email": "beneb.info@gmail.com"
    }
  ],
  "name": "postcss-value-parser",
  "optionalDependencies": {},
  "readme": "# postcss-value-parser\r\n\r\n[![Travis CI](https://travis-ci.org/TrySound/postcss-value-parser.svg)](https://travis-ci.org/TrySound/postcss-value-parser)\r\n\r\nTransforms CSS declaration values and at-rule parameters into a tree of nodes, and provides a simple traversal API.\r\n\r\n## Usage\r\n\r\n```js\r\nvar valueParser = require('postcss-value-parser');\r\nvar cssBackgroundValue = 'url(foo.png) no-repeat 40px 73%';\r\nvar parsedValue = valueParser(cssBackgroundValue);\r\n// parsedValue exposes an API described below,\r\n// e.g. parsedValue.walk(..), parsedValue.toString(), etc.\r\n```\r\n\r\nFor example, parsing the value `rgba(233, 45, 66, .5)` will return the following:\r\n\r\n```js\r\n{\r\n  nodes: [\r\n    {\r\n      type: 'function',\r\n      value: 'rgba',\r\n      before: '',\r\n      after: '',\r\n      nodes: [\r\n        { type: 'word', value: '233' },\r\n        { type: 'div', value: ',', before: '', after: ' ' },\r\n        { type: 'word', value: '45' },\r\n        { type: 'div', value: ',', before: '', after: ' ' },\r\n        { type: 'word', value: '66' },\r\n        { type: 'div', value: ',', before: ' ', after: '' },\r\n        { type: 'word', value: '.5' }\r\n      ]\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\nIf you wanted to convert each `rgba()` value in `sourceCSS` to a hex value, you could do so like this:\r\n\r\n```js\r\nvar valueParser = require('postcss-value-parser');\r\n\r\nvar parsed = valueParser(sourceCSS);\r\n\r\n// walk() will visit all the of the nodes in the tree,\r\n// invoking the callback for each.\r\nparsed.walk(function (node) {\r\n\r\n  // Since we only want to transform rgba() values,\r\n  // we can ignore anything else.\r\n  if (node.type !== 'function' && node.value !== 'rgba') return;\r\n\r\n  // We can make an array of the rgba() arguments to feed to a\r\n  // convertToHex() function\r\n  var color = node.nodes.filter(function (node) {\r\n    return node.type === 'word';\r\n  }).map(function (node) {\r\n    return Number(node.value);\r\n  }); // [233, 45, 66, .5]\r\n\r\n  // Now we will transform the existing rgba() function node\r\n  // into a word node with the hex value\r\n  node.type = 'word';\r\n  node.value = convertToHex(color);\r\n})\r\n\r\nparsed.toString(); // #E92D42\r\n```\r\n\r\n## Nodes\r\n\r\nEach node is an object with these common properties:\r\n\r\n- **type**: The type of node (`word`, `string`, `div`, `space`, `comment`, or `function`).\r\n  Each type is documented below.\r\n- **value**: Each node has a `value` property; but what exactly `value` means\r\n  is specific to the node type. Details are documented for each type below.\r\n- **sourceIndex**: The starting index of the node within the original source\r\n  string. For example, given the source string `10px 20px`, the `word` node\r\n  whose value is `20px` will have a `sourceIndex` of `5`.\r\n\r\n### word\r\n\r\nThe catch-all node type that includes keywords (e.g. `no-repeat`),\r\nquantities (e.g. `20px`, `75%`, `1.5`), and hex colors (e.g. `#e6e6e6`).\r\n\r\nNode-specific properties:\r\n\r\n- **value**: The \"word\" itself.\r\n\r\n### string\r\n\r\nA quoted string value, e.g. `\"something\"` in `content: \"something\";`.\r\n\r\nNode-specific properties:\r\n\r\n- **value**: The text content of the string.\r\n- **quote**: The quotation mark surrounding the string, either `\"` or `'`.\r\n- **unclosed**: `true` if the string was not closed properly. e.g. `\"unclosed string  `.\r\n\r\n### div\r\n\r\nA divider, for example\r\n\r\n- `,` in `animation-duration: 1s, 2s, 3s`\r\n- `/` in `border-radius: 10px / 23px`\r\n- `:` in `(min-width: 700px)`\r\n\r\nNode-specific properties:\r\n\r\n- **value**: The divider character. Either `,`, `/`, or `:` (see examples above).\r\n- **before**: Whitespace before the divider.\r\n- **after**: Whitespace after the divider.\r\n\r\n### space\r\n\r\nWhitespace used as a separator, e.g. ` ` occurring twice in `border: 1px solid black;`.\r\n\r\nNode-specific properties:\r\n\r\n- **value**: The whitespace itself.\r\n\r\n### comment\r\n\r\nA CSS comment starts with `/*` and ends with `*/`\r\n\r\nNode-specific properties:\r\n\r\n- **value**: The comment value without `/*` and `*/`\r\n- **unclosed**: `true` if the comment was not closed properly. e.g. `/* comment without an end  `.\r\n\r\n### function\r\n\r\nA CSS function, e.g. `rgb(0,0,0)` or `url(foo.bar)`.\r\n\r\nFunction nodes have nodes nested within them: the function arguments.\r\n\r\nAdditional properties:\r\n\r\n- **value**: The name of the function, e.g. `rgb` in `rgb(0,0,0)`.\r\n- **before**: Whitespace after the opening parenthesis and before the first argument,\r\n  e.g. `  ` in `rgb(  0,0,0)`.\r\n- **after**: Whitespace before the closing parenthesis and after the last argument,\r\n  e.g. `  ` in `rgb(0,0,0  )`.\r\n- **nodes**: More nodes representing the arguments to the function.\r\n- **unclosed**: `true` if the parentheses was not closed properly. e.g. `( unclosed-function  `.\r\n\r\nMedia features surrounded by parentheses are considered functions with an\r\nempty value. For example, `(min-width: 700px)` parses to these nodes:\r\n\r\n```js\r\n[\r\n  {\r\n    type: 'function', value: '', before: '', after: '',\r\n    nodes: [\r\n      { type: 'word', value: 'min-width' },\r\n      { type: 'div', value: ':', before: '', after: ' ' },\r\n      { type: 'word', value: '700px' }\r\n    ]\r\n  }\r\n]\r\n```\r\n\r\n`url()` functions can be parsed a little bit differently depending on\r\nwhether the first character in the argument is a quotation mark.\r\n\r\n`url( /gfx/img/bg.jpg )` parses to:\r\n\r\n```js\r\n{ type: 'function', sourceIndex: 0, value: 'url', before: ' ', after: ' ', nodes: [\r\n    { type: 'word', sourceIndex: 5, value: '/gfx/img/bg.jpg' }\r\n] }\r\n```\r\n\r\n`url( \"/gfx/img/bg.jpg\" )`, on the other hand, parses to:\r\n\r\n```js\r\n{ type: 'function', sourceIndex: 0, value: 'url', before: ' ', after: ' ', nodes: [\r\n     type: 'string', sourceIndex: 5, quote: '\"', value: '/gfx/img/bg.jpg' },\r\n] }\r\n```\r\n\r\n## API\r\n\r\n```\r\nvar valueParser = require('postcss-value-parser');\r\n```\r\n\r\n### valueParser.unit(quantity)\r\n\r\nParses `quantity`, distinguishing the number from the unit. Returns an object like the following:\r\n\r\n```js\r\n// Given 2rem\r\n{\r\n  number: '2',\r\n  unit: 'rem'\r\n}\r\n```\r\n\r\nIf the `quantity` argument cannot be parsed as a number, returns `false`.\r\n\r\n*This function does not parse complete values*: you cannot pass it `1px solid black` and expect `px` as\r\nthe unit. Instead, you should pass it single quantities only. Parse `1px solid black`, then pass it\r\nthe stringified `1px` node (a `word` node) to parse the number and unit.\r\n\r\n### valueParser.stringify(nodes[, custom])\r\n\r\nStringifies a node or array of nodes.\r\n\r\nThe `custom` function is called for each `node`; return a string to override the default behaviour.\r\n\r\n### valueParser.walk(nodes, callback[, bubble])\r\n\r\nWalks each provided node, recursively walking all descendent nodes within functions.\r\n\r\nReturning `false` in the `callback` will prevent traversal of descendent nodes (within functions).\r\nYou can use this feature to for shallow iteration, walking over only the *immediate* children.\r\n*Note: This only applies if `bubble` is `false` (which is the default).*\r\n\r\nBy default, the tree is walked from the outermost node inwards.\r\nTo reverse the direction, pass `true` for the `bubble` argument.\r\n\r\nThe `callback` is invoked with three arguments: `callback(node, index, nodes)`.\r\n\r\n- `node`: The current node.\r\n- `index`: The index of the current node.\r\n- `nodes`: The complete nodes array passed to `walk()`.\r\n\r\nReturns the `valueParser` instance.\r\n\r\n### var parsed = valueParser(value)\r\n\r\nReturns the parsed node tree.\r\n\r\n### parsed.nodes\r\n\r\nThe array of nodes.\r\n\r\n### parsed.toString()\r\n\r\nStringifies the node tree.\r\n\r\n### parsed.walk(callback[, bubble])\r\n\r\nWalks each node inside `parsed.nodes`. See the documentation for `valueParser.walk()` above.\r\n\r\n# License\r\n\r\nMIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)\r\n",
  "readmeFilename": "README.md",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/TrySound/postcss-value-parser.git"
  },
  "scripts": {
    "posttest": "eslint .",
    "test": "tape test/*.js | tap-spec"
  },
  "version": "3.3.0"
}