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

postcss-clamp

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-clamp - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

4

CHANGELOG.md
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
## 2.0.0
* Rewrite package to PostCSS 8 (#2)
## 1.1.0

@@ -5,0 +9,0 @@

38

index.js

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

let postcss = require('postcss')
let valueParser = require('postcss-value-parser')

@@ -23,8 +22,9 @@

module.exports = postcss.plugin('postcss-clamp', opts => {
module.exports = opts => {
opts = opts || {}
let precalculate = opts.precalculate ? Boolean(opts.precalculate) : false
return function (css) {
css.walkDecls(decl => {
return {
postcssPlugin: 'postcss-clamp',
Declaration (decl) {
if (!decl || !decl.value.includes('clamp')) {

@@ -42,7 +42,5 @@ return

}
let first = nodes[0]
let second = nodes[2]
let third = nodes[4]
let naive = compose(

@@ -53,11 +51,12 @@ valueParser.stringify(first),

)
if (!precalculate || second.type !== 'word' || third.type !== 'word') {
if (
!precalculate ||
second.type !== 'word' ||
third.type !== 'word'
) {
decl.value = naive
return
}
let parsedSecond = parseValue(second.value)
let parsedThird = parseValue(third.value)
if (parsedSecond === undefined || parsedThird === undefined) {

@@ -67,6 +66,4 @@ decl.value = naive

}
let [secondValue, secondUnit] = parsedSecond
let [thirdValue, thirdUnit] = parsedThird
if (secondUnit !== thirdUnit) {

@@ -76,24 +73,23 @@ decl.value = naive

}
let parsedFirst = parseValue(first.value)
if (parsedFirst === undefined) {
let secondThirdValue = `${ secondValue + thirdValue }${ secondUnit }`
let secondThirdValue =
`${ secondValue + thirdValue }${ secondUnit }`
decl.value = compose(valueParser.stringify(first), secondThirdValue)
return
}
let [firstValue, firstUnit] = parsedFirst
if (firstUnit !== secondUnit) {
let secondThirdValue = `${ secondValue + thirdValue }${ secondUnit }`
let secondThirdValue =
`${ secondValue + thirdValue }${ secondUnit }`
decl.value = compose(valueParser.stringify(first), secondThirdValue)
return
}
decl.value =
compose(`${ firstValue + secondValue + thirdValue }${ secondUnit }`)
})
})
}
}
})
}
module.exports.postcss = true
{
"name": "postcss-clamp",
"version": "1.1.0",
"version": "2.0.0",
"description": "PostCSS plugin to transform clamp() to combination of min/max",

@@ -18,5 +18,7 @@ "keywords": [

"dependencies": {
"postcss": "^7.0.29",
"postcss-value-parser": "^4.1.0"
},
"peerDependencies": {
"postcss": "^8.1.1"
},
"engines": {

@@ -23,0 +25,0 @@ "node": ">=7.6.0"

@@ -47,5 +47,5 @@ # PostCSS Clamp

```bash
$ npm install postcss-clamp --save-dev
$ npm install postcss postcss-clamp --save-dev
or
$ yarn add --dev postcss-clamp
$ yarn add --dev postcss postcss-clamp
```

@@ -52,0 +52,0 @@

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