🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@onelinecode/onelinecode

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onelinecode/onelinecode - npm Package Compare versions

Comparing version
1.12.0
to
1.13.0
+8
src/array/odd-item.js
/**
* Returns an array which contains every odd (second) item of the original array.
* @param {Array} arr
* @returns {Array}
*/
const fn = (arr) => arr.filter((arr, index) => index % 2 === 2 - 1);
export default fn;
import { oddItem } from '../../src/array';
const test = require('ava');
test('returns en empty array it the array has only one item', t => {
let input = ['foo'];
let expectation = [];
t.deepEqual(oddItem(input), expectation);
});
test('returns every second item of a string with an even number of items', t => {
let input = ['foo', 'bar', 'baz', 'foobar'];
let expectation = ['bar', 'foobar'];
t.deepEqual(oddItem(input), expectation);
});
test('returns every second item of a string with an uneven number of items', t => {
let input = ['foo', 'bar', 'baz', 'foobar', 'barbaz'];
let expectation = ['bar', 'foobar'];
t.deepEqual(oddItem(input), expectation);
});
+12
-0

@@ -0,1 +1,13 @@

# [1.13.0](https://github.com/martinkr/onelinecode/compare/v1.12.0...v1.13.0) (2021-11-09)
### Bug Fixes
* **Array/oddItem:** fix spec ([70df948](https://github.com/martinkr/onelinecode/commit/70df948615c9ec7384fdfea2f8925f71aa3dfccc))
### Features
* **Array/oddItem:** Returns an array which contains every odd (second) item of the original array. ([2ec177d](https://github.com/martinkr/onelinecode/commit/2ec177dbc7048aab4d5a95c438e50eafafbff176))
# [1.12.0](https://github.com/martinkr/onelinecode/compare/v1.11.0...v1.12.0) (2021-11-08)

@@ -2,0 +14,0 @@

+1
-1
// ! onelinecode vv1.5.5
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=Object.freeze({__proto__:null,isEmpty:({length:e})=>0===e,removeDuplicates:e=>[...new Set(e)],occurrenceMap:e=>e.reduce(((e,t)=>(e[t]=(e[t]||0)+1,e)),{}),shallowClone:e=>e.slice(0),lowestNumber:e=>Math.min(...e),highestNumber:e=>Math.max(...e),closestNumber:(e,t)=>e.reduce(((e,l)=>Math.abs(l-t)<Math.abs(e-t)?l:e)),indexOfLowestNumber:e=>e.indexOf(Math.min.apply(null,e)),indexOfHighestNumber:e=>e.indexOf(Math.max.apply(null,e)),splitInHalf:e=>[e.slice(0,Math.ceil(e.length/2)),e.slice(Math.ceil(e.length/2))],longestString:e=>e.reduce(((e,t)=>e.length>t.length?e:t)),shortestString:e=>e.reduce(((e,t)=>e.length<t.length?e:t)),shortestStringLength:(e,t=1/0)=>(e.forEach((e=>{e.length<t&&(t=e.length)})),t),longestStringLength:(e,t=0)=>(e.forEach((e=>{e.length>t&&(t=e.length)})),t)});exports.arr=e;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=Object.freeze({__proto__:null,isEmpty:({length:e})=>0===e,removeDuplicates:e=>[...new Set(e)],occurrenceMap:e=>e.reduce(((e,t)=>(e[t]=(e[t]||0)+1,e)),{}),shallowClone:e=>e.slice(0),lowestNumber:e=>Math.min(...e),highestNumber:e=>Math.max(...e),closestNumber:(e,t)=>e.reduce(((e,l)=>Math.abs(l-t)<Math.abs(e-t)?l:e)),indexOfLowestNumber:e=>e.indexOf(Math.min.apply(null,e)),indexOfHighestNumber:e=>e.indexOf(Math.max.apply(null,e)),splitInHalf:e=>[e.slice(0,Math.ceil(e.length/2)),e.slice(Math.ceil(e.length/2))],longestString:e=>e.reduce(((e,t)=>e.length>t.length?e:t)),shortestString:e=>e.reduce(((e,t)=>e.length<t.length?e:t)),shortestStringLength:(e,t=1/0)=>(e.forEach((e=>{e.length<t&&(t=e.length)})),t),longestStringLength:(e,t=0)=>(e.forEach((e=>{e.length>t&&(t=e.length)})),t),oddItem:e=>e.filter(((e,t)=>t%2==1))});exports.arr=e;
// ! onelinecode vv1.5.5
var e=Object.freeze({__proto__:null,isEmpty:({length:e})=>0===e,removeDuplicates:e=>[...new Set(e)],occurrenceMap:e=>e.reduce(((e,t)=>(e[t]=(e[t]||0)+1,e)),{}),shallowClone:e=>e.slice(0),lowestNumber:e=>Math.min(...e),highestNumber:e=>Math.max(...e),closestNumber:(e,t)=>e.reduce(((e,l)=>Math.abs(l-t)<Math.abs(e-t)?l:e)),indexOfLowestNumber:e=>e.indexOf(Math.min.apply(null,e)),indexOfHighestNumber:e=>e.indexOf(Math.max.apply(null,e)),splitInHalf:e=>[e.slice(0,Math.ceil(e.length/2)),e.slice(Math.ceil(e.length/2))],longestString:e=>e.reduce(((e,t)=>e.length>t.length?e:t)),shortestString:e=>e.reduce(((e,t)=>e.length<t.length?e:t)),shortestStringLength:(e,t=1/0)=>(e.forEach((e=>{e.length<t&&(t=e.length)})),t),longestStringLength:(e,t=0)=>(e.forEach((e=>{e.length>t&&(t=e.length)})),t)});export{e as arr};
var e=Object.freeze({__proto__:null,isEmpty:({length:e})=>0===e,removeDuplicates:e=>[...new Set(e)],occurrenceMap:e=>e.reduce(((e,t)=>(e[t]=(e[t]||0)+1,e)),{}),shallowClone:e=>e.slice(0),lowestNumber:e=>Math.min(...e),highestNumber:e=>Math.max(...e),closestNumber:(e,t)=>e.reduce(((e,l)=>Math.abs(l-t)<Math.abs(e-t)?l:e)),indexOfLowestNumber:e=>e.indexOf(Math.min.apply(null,e)),indexOfHighestNumber:e=>e.indexOf(Math.max.apply(null,e)),splitInHalf:e=>[e.slice(0,Math.ceil(e.length/2)),e.slice(Math.ceil(e.length/2))],longestString:e=>e.reduce(((e,t)=>e.length>t.length?e:t)),shortestString:e=>e.reduce(((e,t)=>e.length<t.length?e:t)),shortestStringLength:(e,t=1/0)=>(e.forEach((e=>{e.length<t&&(t=e.length)})),t),longestStringLength:(e,t=0)=>(e.forEach((e=>{e.length>t&&(t=e.length)})),t),oddItem:e=>e.filter(((e,t)=>t%2==1))});export{e as arr};
// ! onelinecode vv1.5.5
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).onelinecode={})}(this,(function(e){"use strict";var t=Object.freeze({__proto__:null,isEmpty:({length:e})=>0===e,removeDuplicates:e=>[...new Set(e)],occurrenceMap:e=>e.reduce(((e,t)=>(e[t]=(e[t]||0)+1,e)),{}),shallowClone:e=>e.slice(0),lowestNumber:e=>Math.min(...e),highestNumber:e=>Math.max(...e),closestNumber:(e,t)=>e.reduce(((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e)),indexOfLowestNumber:e=>e.indexOf(Math.min.apply(null,e)),indexOfHighestNumber:e=>e.indexOf(Math.max.apply(null,e)),splitInHalf:e=>[e.slice(0,Math.ceil(e.length/2)),e.slice(Math.ceil(e.length/2))],longestString:e=>e.reduce(((e,t)=>e.length>t.length?e:t)),shortestString:e=>e.reduce(((e,t)=>e.length<t.length?e:t)),shortestStringLength:(e,t=1/0)=>(e.forEach((e=>{e.length<t&&(t=e.length)})),t),longestStringLength:(e,t=0)=>(e.forEach((e=>{e.length>t&&(t=e.length)})),t)});e.arr=t,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).onelinecode={})}(this,(function(e){"use strict";var t=Object.freeze({__proto__:null,isEmpty:({length:e})=>0===e,removeDuplicates:e=>[...new Set(e)],occurrenceMap:e=>e.reduce(((e,t)=>(e[t]=(e[t]||0)+1,e)),{}),shallowClone:e=>e.slice(0),lowestNumber:e=>Math.min(...e),highestNumber:e=>Math.max(...e),closestNumber:(e,t)=>e.reduce(((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e)),indexOfLowestNumber:e=>e.indexOf(Math.min.apply(null,e)),indexOfHighestNumber:e=>e.indexOf(Math.max.apply(null,e)),splitInHalf:e=>[e.slice(0,Math.ceil(e.length/2)),e.slice(Math.ceil(e.length/2))],longestString:e=>e.reduce(((e,t)=>e.length>t.length?e:t)),shortestString:e=>e.reduce(((e,t)=>e.length<t.length?e:t)),shortestStringLength:(e,t=1/0)=>(e.forEach((e=>{e.length<t&&(t=e.length)})),t),longestStringLength:(e,t=0)=>(e.forEach((e=>{e.length>t&&(t=e.length)})),t),oddItem:e=>e.filter(((e,t)=>t%2==1))});e.arr=t,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@onelinecode/onelinecode",
"version": "1.12.0",
"version": "1.13.0",
"description": "Awesome javascript in one line of code",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -14,2 +14,3 @@ export { default as isEmpty } from './is-empty';

export { default as shortestStringLength } from './shortest-string-length.js';
export { default as longestStringLength } from './longest-string-length.js';
export { default as longestStringLength } from './longest-string-length.js';
export { default as oddItem } from './odd-item.js';

@@ -57,1 +57,5 @@ import * as Array from '../../src/array';

});
test('exports a function "(Array.)oddItem"', t => {
t.true(typeof (Array.oddItem) === 'function')
});

@@ -58,1 +58,5 @@ import { arr } from '../src';

});
test('exports a function "(arr.)oddItem"', t => {
t.true(typeof (arr.oddItem) === 'function')
});