New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@unction/append

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unction/append - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

.nyc_output/363fa749638cc9b21031730f95f4f7ec.json

5

package.json
{
"name": "@unction/append",
"version": "2.0.0",
"version": "2.1.0",
"description": "Takes a value and puts it at the end of the given list",

@@ -57,3 +57,6 @@ "keywords": [

"instrument": false
},
"dependencies": {
"@unction/type": "2.0.0"
}
}
# @unction/append
![Tests][BADGE_TRAVIS]

@@ -8,13 +7,16 @@ ![Stability][BADGE_STABILITY]

> any -> Array<any> -> Array<any>
> mixed -> (ArrayType | string) -> (ArrayType | string)
Takes a value and puts it at the end of the given list
Takes a value and puts it at the end of the given list.
``` javascript
append(4)([5]) // => [5, 4]
append("c")("ab") // => "abc"
```
> NOTE: While there is a type annotation in the README, this function cannot have type annotations due to a bug in flow.
[BADGE_TRAVIS]: https://img.shields.io/travis/unctionjs/append.svg?maxAge=2592000&style=flat-square
[BADGE_STABILITY]: https://img.shields.io/badge/stability-strong-green.svg?maxAge=2592000&style=flat-square
[BADGE_DEPENDENCY]: https://img.shields.io/david/unctionjs/append.svg?maxAge=2592000&style=flat-square

20

source.js

@@ -1,5 +0,19 @@

export default function append (left: any): Function {
return function appendLeft (right: Array<any>): Array<any> {
return [...right, left]
/* eslint-disable no-extra-parens, no-unused-expressions */
import type from "@unction/type"
export default function append (value: any): Function {
return function appendLeft (orderedList: any): any {
switch (type(orderedList)) {
case "String": {
return `${orderedList}${value}`
}
case "Array": {
return [...orderedList, value]
}
default: {
throw new Error(`append doesn't know how to deal with ${type(orderedList)}`)
}
}
}
}

@@ -11,1 +11,13 @@ /* eslint-disable flowtype/require-parameter-type, flowtype/require-return-type */

})
test(({same, end}) => {
same(append("c")("ab"), "abc")
end()
})
test(({throws, end}) => {
throws(() => append("c")({}))
end()
})

@@ -8,8 +8,27 @@ "use strict";

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var _type = require("@unction/type");
function append(left) {
return function appendLeft(right) {
return [].concat(_toConsumableArray(right), [left]);
var _type2 = _interopRequireDefault(_type);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } /* eslint-disable no-extra-parens, no-unused-expressions */
function append(value) {
return function appendLeft(orderedList) {
switch ((0, _type2.default)(orderedList)) {
case "String":
{
return "" + orderedList + value;
}
case "Array":
{
return [].concat(_toConsumableArray(orderedList), [value]);
}
default:
{
throw new Error("append doesn't know how to deal with " + (0, _type2.default)(orderedList));
}
}
};
}
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