├── .gitignore ├── 3sc.alfredsnippets ├── README.md ├── dist ├── JSONToFile[acf4270c-3d81-11e8-ad5b-acde48001122].json ├── RGBToHex[acfd2636-3d81-11e8-a29e-acde48001122].json ├── URLJoin[acf9a706-3d81-11e8-943d-acde48001122].json ├── UUIDGeneratorBrowser[acfd94e8-3d81-11e8-87f6-acde48001122].json ├── UUIDGeneratorNode[acf49868-3d81-11e8-b868-acde48001122].json ├── all[ad01a724-3d81-11e8-b745-acde48001122].json ├── any[acfae9b6-3d81-11e8-bc58-acde48001122].json ├── approximatelyEqual[ad01ce70-3d81-11e8-847e-acde48001122].json ├── arrayToHtmlList[acfa83a4-3d81-11e8-9b27-acde48001122].json ├── ary[acfd07dc-3d81-11e8-9148-acde48001122].json ├── atob[acf69f28-3d81-11e8-a17d-acde48001122].json ├── attempt[acfe0b8c-3d81-11e8-bfd8-acde48001122].json ├── averageBy[acf79086-3d81-11e8-a63a-acde48001122].json ├── average[acfa38e8-3d81-11e8-aeaf-acde48001122].json ├── bifurcateBy[acff5bcc-3d81-11e8-aa99-acde48001122].json ├── bifurcate[acfc23e4-3d81-11e8-997b-acde48001122].json ├── bindAll[acfc934c-3d81-11e8-8c9f-acde48001122].json ├── bindKey[acfe569e-3d81-11e8-9f72-acde48001122].json ├── bind[acf65cb6-3d81-11e8-a418-acde48001122].json ├── binomialCoefficient[acfb4938-3d81-11e8-befa-acde48001122].json ├── bottomVisible[acf3d3b0-3d81-11e8-922d-acde48001122].json ├── btoa[acfb6436-3d81-11e8-863d-acde48001122].json ├── byteSize[acfa2ba2-3d81-11e8-9c49-acde48001122].json ├── call[acfa5db6-3d81-11e8-af81-acde48001122].json ├── capitalizeEveryWord[acfc5f94-3d81-11e8-b217-acde48001122].json ├── capitalize[acf85bd8-3d81-11e8-81da-acde48001122].json ├── castArray[acfc439c-3d81-11e8-ab77-acde48001122].json ├── chainAsync[acfb9230-3d81-11e8-9cc8-acde48001122].json ├── chunk[ad014914-3d81-11e8-9094-acde48001122].json ├── clampNumber[acfc0922-3d81-11e8-841f-acde48001122].json ├── cloneRegExp[acf86b50-3d81-11e8-b0be-acde48001122].json ├── coalesceFactory[acf7ff76-3d81-11e8-a5e6-acde48001122].json ├── coalesce[ad032130-3d81-11e8-ac13-acde48001122].json ├── collectInto[ad02dd42-3d81-11e8-84e2-acde48001122].json ├── colorize[acfaa708-3d81-11e8-88e1-acde48001122].json ├── compact[ad00ff7a-3d81-11e8-8061-acde48001122].json ├── composeRight[acfd16fa-3d81-11e8-bc26-acde48001122].json ├── compose[acfcae5e-3d81-11e8-ab18-acde48001122].json ├── converge[acfa07e4-3d81-11e8-89b9-acde48001122].json ├── copyToClipboard[ad008dee-3d81-11e8-bc5c-acde48001122].json ├── countBy[acf4a77a-3d81-11e8-b53a-acde48001122].json ├── countOccurrences[acf83f5e-3d81-11e8-8159-acde48001122].json ├── createElement[ad02ef62-3d81-11e8-9c4d-acde48001122].json ├── createEventHub[acfbf7ca-3d81-11e8-b114-acde48001122].json ├── currentURL[acfe38e6-3d81-11e8-b54d-acde48001122].json ├── curry[acf431ac-3d81-11e8-8f53-acde48001122].json ├── debounce[acfad430-3d81-11e8-a8a5-acde48001122].json ├── decapitalize[ad021ce8-3d81-11e8-896a-acde48001122].json ├── deepClone[acf5a958-3d81-11e8-ac2f-acde48001122].json ├── deepFlatten[ad03af42-3d81-11e8-af3c-acde48001122].json ├── defaults[acf4541e-3d81-11e8-abd0-acde48001122].json ├── defer[acf3be8c-3d81-11e8-858f-acde48001122].json ├── degreesToRads[acf72b50-3d81-11e8-a163-acde48001122].json ├── delay[acf4133e-3d81-11e8-9892-acde48001122].json ├── detectDeviceType[acf92fd8-3d81-11e8-a9b8-acde48001122].json ├── differenceBy[acf60798-3d81-11e8-b644-acde48001122].json ├── differenceWith[acf3aa34-3d81-11e8-8e28-acde48001122].json ├── difference[acfca33a-3d81-11e8-91da-acde48001122].json ├── digitize[acfab786-3d81-11e8-82b4-acde48001122].json ├── distance[ad013e62-3d81-11e8-80c4-acde48001122].json ├── dropRightWhile[acf68418-3d81-11e8-b9e5-acde48001122].json ├── dropRight[acf5bdc6-3d81-11e8-93f3-acde48001122].json ├── dropWhile[ad00be40-3d81-11e8-b7a6-acde48001122].json ├── drop[acf8e56c-3d81-11e8-9648-acde48001122].json ├── elementIsVisibleInViewport[ad005a7a-3d81-11e8-98c8-acde48001122].json ├── elo[acfda534-3d81-11e8-ade4-acde48001122].json ├── equals[acfde562-3d81-11e8-b4a6-acde48001122].json ├── escapeHTML[acfcb87a-3d81-11e8-a2a9-acde48001122].json ├── escapeRegExp[acf5d750-3d81-11e8-a438-acde48001122].json ├── everyNth[acf8ba62-3d81-11e8-a2d0-acde48001122].json ├── extendHex[acf79b46-3d81-11e8-852e-acde48001122].json ├── factorial[acf54092-3d81-11e8-8caa-acde48001122].json ├── fibonacci[acf7bfca-3d81-11e8-814d-acde48001122].json ├── filterNonUnique[ad02af48-3d81-11e8-8de3-acde48001122].json ├── findKey[acfac878-3d81-11e8-8ffe-acde48001122].json ├── findLastIndex[acfce11c-3d81-11e8-8f3b-acde48001122].json ├── findLastKey[acf3814c-3d81-11e8-addc-acde48001122].json ├── findLast[ad012452-3d81-11e8-a44b-acde48001122].json ├── flattenObject[acfd325c-3d81-11e8-bb79-acde48001122].json ├── flatten[acfb8452-3d81-11e8-8094-acde48001122].json ├── flip[acf473ec-3d81-11e8-8782-acde48001122].json ├── forEachRight[acf9fa2e-3d81-11e8-ba3b-acde48001122].json ├── forOwnRight[acfb1b34-3d81-11e8-87f4-acde48001122].json ├── forOwn[ad019842-3d81-11e8-8eee-acde48001122].json ├── formatDuration[acf96910-3d81-11e8-af5b-acde48001122].json ├── fromCamelCase[acff6c1e-3d81-11e8-a7d1-acde48001122].json ├── functionName[acfa1ec8-3d81-11e8-a016-acde48001122].json ├── functions[acfdda18-3d81-11e8-94ff-acde48001122].json ├── gcd[ad03c074-3d81-11e8-a2ca-acde48001122].json ├── geometricProgression[ad004e58-3d81-11e8-82fd-acde48001122].json ├── getColonTimeFromDate[ad0153b4-3d81-11e8-a042-acde48001122].json ├── getDaysDiffBetweenDates[acf9effa-3d81-11e8-ac2a-acde48001122].json ├── getMeridiemSuffixOfInteger[ad0309c0-3d81-11e8-a5f2-acde48001122].json ├── getScrollPosition[acf78528-3d81-11e8-99e0-acde48001122].json ├── getStyle[ad0350c6-3d81-11e8-b820-acde48001122].json ├── getType[acf7cbb4-3d81-11e8-82fe-acde48001122].json ├── getURLParameters[acfe4874-3d81-11e8-85a3-acde48001122].json ├── get[acf7afc6-3d81-11e8-b656-acde48001122].json ├── groupBy[acf80a1e-3d81-11e8-8463-acde48001122].json ├── hammingDistance[ad00a868-3d81-11e8-bd6e-acde48001122].json ├── hasClass[acff13ba-3d81-11e8-a5f1-acde48001122].json ├── hasFlags[acf916e2-3d81-11e8-816a-acde48001122].json ├── hashBrowser[acffa26c-3d81-11e8-b059-acde48001122].json ├── hashNode[ad026d76-3d81-11e8-a366-acde48001122].json ├── head[acf37712-3d81-11e8-b816-acde48001122].json ├── hexToRGB[acf45e18-3d81-11e8-9c41-acde48001122].json ├── hide[acf449da-3d81-11e8-8a30-acde48001122].json ├── httpGet[acfeaa74-3d81-11e8-b787-acde48001122].json ├── httpPost[acfcf6ac-3d81-11e8-90a0-acde48001122].json ├── httpsRedirect[acf631dc-3d81-11e8-8a8d-acde48001122].json ├── inRange[acfbb08a-3d81-11e8-bcd8-acde48001122].json ├── indexOfAll[acfa792c-3d81-11e8-84da-acde48001122].json ├── initial[acf58a48-3d81-11e8-af88-acde48001122].json ├── initialize2DArray[ad00000c-3d81-11e8-8f52-acde48001122].json ├── initializeArrayWithRangeRight[ad00dd62-3d81-11e8-bef2-acde48001122].json ├── initializeArrayWithRange[acff452e-3d81-11e8-91f4-acde48001122].json ├── initializeArrayWithValues[acfa8ed0-3d81-11e8-b3de-acde48001122].json ├── intersectionBy[acffd798-3d81-11e8-90f4-acde48001122].json ├── intersectionWith[acf6b562-3d81-11e8-9019-acde48001122].json ├── intersection[acfa6e1e-3d81-11e8-85be-acde48001122].json ├── invertKeyValues[acf82f98-3d81-11e8-84d5-acde48001122].json ├── isAbsoluteURL[ad002018-3d81-11e8-92b8-acde48001122].json ├── isAnagram[acf4ed18-3d81-11e8-8db6-acde48001122].json ├── isArrayLike[acf62692-3d81-11e8-b145-acde48001122].json ├── isBoolean[acf3c958-3d81-11e8-aa54-acde48001122].json ├── isBrowser[ad03979e-3d81-11e8-8a94-acde48001122].json ├── isDivisible[acf8fc78-3d81-11e8-808b-acde48001122].json ├── isEmpty[acfd6358-3d81-11e8-9db5-acde48001122].json ├── isEven[ad010bde-3d81-11e8-b790-acde48001122].json ├── isFunction[acf974b4-3d81-11e8-9d7f-acde48001122].json ├── isLowerCase[ad008346-3d81-11e8-98bc-acde48001122].json ├── isNil[acfb593a-3d81-11e8-b4b4-acde48001122].json ├── isNull[acffc792-3d81-11e8-9cb8-acde48001122].json ├── isNumber[acf6dae2-3d81-11e8-aea4-acde48001122].json ├── isObjectLike[ad03da94-3d81-11e8-8721-acde48001122].json ├── isObject[acf93f3a-3d81-11e8-80fc-acde48001122].json ├── isPlainObject[acf469cc-3d81-11e8-8486-acde48001122].json ├── isPrime[ad027a34-3d81-11e8-8d07-acde48001122].json ├── isPrimitive[acfafef6-3d81-11e8-9bc8-acde48001122].json ├── isPromiseLike[acf4dcc6-3d81-11e8-8470-acde48001122].json ├── isSorted[acfe6318-3d81-11e8-b7df-acde48001122].json ├── isString[acfe1b22-3d81-11e8-8b67-acde48001122].json ├── isSymbol[acf40966-3d81-11e8-a735-acde48001122].json ├── isTravisCI[acfb3a42-3d81-11e8-86b6-acde48001122].json ├── isUndefined[acfe7f5e-3d81-11e8-8528-acde48001122].json ├── isUpperCase[acfd3fa4-3d81-11e8-abcf-acde48001122].json ├── isValidJSON[ad023cde-3d81-11e8-b862-acde48001122].json ├── is[ad02a412-3d81-11e8-9f61-acde48001122].json ├── join[ad015dc8-3d81-11e8-9efb-acde48001122].json ├── last[acf3ffb6-3d81-11e8-8941-acde48001122].json ├── lcm[acf5e45c-3d81-11e8-a7ae-acde48001122].json ├── longestItem[ad01d942-3d81-11e8-829f-acde48001122].json ├── lowercaseKeys[acf50fb4-3d81-11e8-9406-acde48001122].json ├── luhnCheck[acf71b62-3d81-11e8-920c-acde48001122].json ├── mapKeys[ad0284f0-3d81-11e8-9e30-acde48001122].json ├── mapObject[ad006a8a-3d81-11e8-ac1b-acde48001122].json ├── mapValues[ad01b46c-3d81-11e8-b0cc-acde48001122].json ├── mask[acfdc028-3d81-11e8-8973-acde48001122].json ├── matchesWith[acf5258a-3d81-11e8-908d-acde48001122].json ├── matches[acfe9ec6-3d81-11e8-bbda-acde48001122].json ├── maxBy[ad025a0c-3d81-11e8-9e40-acde48001122].json ├── maxN[acf8863a-3d81-11e8-a199-acde48001122].json ├── median[acf38ee6-3d81-11e8-9a06-acde48001122].json ├── memoize[acff9740-3d81-11e8-bd7b-acde48001122].json ├── merge[acfe8f80-3d81-11e8-a528-acde48001122].json ├── minBy[ad01c2c2-3d81-11e8-b216-acde48001122].json ├── minN[ad018622-3d81-11e8-8d76-acde48001122].json ├── mostPerformant[acfd823e-3d81-11e8-aad4-acde48001122].json ├── negate[ad038be8-3d81-11e8-86bf-acde48001122].json ├── nest[acfc37e4-3d81-11e8-9e05-acde48001122].json ├── none[acfee6a6-3d81-11e8-b488-acde48001122].json ├── nthArg[acf748a6-3d81-11e8-859a-acde48001122].json ├── nthElement[acf650d8-3d81-11e8-83d3-acde48001122].json ├── objectFromPairs[acf9e19c-3d81-11e8-b764-acde48001122].json ├── objectToPairs[acfbcc9e-3d81-11e8-a488-acde48001122].json ├── observeMutations[ad00ee68-3d81-11e8-8aaa-acde48001122].json ├── off[acfc6e76-3d81-11e8-819d-acde48001122].json ├── offset[ad016908-3d81-11e8-baab-acde48001122].json ├── omitBy[acf906b4-3d81-11e8-96f5-acde48001122].json ├── omit[acfdf2d2-3d81-11e8-9abd-acde48001122].json ├── onUserInputChange[acf63fec-3d81-11e8-ada4-acde48001122].json ├── on[ad024c92-3d81-11e8-beb5-acde48001122].json ├── once[acf579fe-3d81-11e8-bc51-acde48001122].json ├── orderBy[acf9b5c8-3d81-11e8-8eac-acde48001122].json ├── overArgs[acf17822-3d81-11e8-b4d0-acde48001122].json ├── over[acf7d726-3d81-11e8-bd7a-acde48001122].json ├── pad[acf5b3d8-3d81-11e8-bcaf-acde48001122].json ├── palindrome[acfeba34-3d81-11e8-a971-acde48001122].json ├── parseCookie[acfb0ec8-3d81-11e8-b9c6-acde48001122].json ├── partialRight[acf6a998-3d81-11e8-9f6d-acde48001122].json ├── partial[acf94fe8-3d81-11e8-83ea-acde48001122].json ├── partition[acfc2de4-3d81-11e8-82d5-acde48001122].json ├── percentile[acf84e9a-3d81-11e8-baa6-acde48001122].json ├── permutations[acfff000-3d81-11e8-9d7a-acde48001122].json ├── pickBy[ad020d22-3d81-11e8-b613-acde48001122].json ├── pick[acf59d80-3d81-11e8-91a6-acde48001122].json ├── pipeAsyncFunctions[ad02ce06-3d81-11e8-b61b-acde48001122].json ├── pipeFunctions[acf41d02-3d81-11e8-848c-acde48001122].json ├── pluralize[acf4b28a-3d81-11e8-97c3-acde48001122].json ├── powerset[acf3b452-3d81-11e8-8f36-acde48001122].json ├── prefix[acfdcb18-3d81-11e8-ac83-acde48001122].json ├── prettyBytes[ad017628-3d81-11e8-b7d7-acde48001122].json ├── primes[acfd4ee8-3d81-11e8-9129-acde48001122].json ├── promisify[acf4806c-3d81-11e8-81f4-acde48001122].json ├── pullAtIndex[acfdb4ca-3d81-11e8-88fb-acde48001122].json ├── pullAtValue[acf8238c-3d81-11e8-a897-acde48001122].json ├── pullBy[acf8f086-3d81-11e8-ae41-acde48001122].json ├── pull[acfc50c6-3d81-11e8-8082-acde48001122].json ├── radsToDegrees[acf75936-3d81-11e8-8e18-acde48001122].json ├── randomHexColorCode[acf6c412-3d81-11e8-bbd9-acde48001122].json ├── randomIntArrayInRange[acf7a5ba-3d81-11e8-821e-acde48001122].json ├── randomIntegerInRange[ad007822-3d81-11e8-ac75-acde48001122].json ├── randomNumberInRange[acfdfeba-3d81-11e8-9926-acde48001122].json ├── readFileLines[acfb7354-3d81-11e8-ad1d-acde48001122].json ├── rearg[ad02fc9e-3d81-11e8-8163-acde48001122].json ├── recordAnimationFrames[acf6fb8a-3d81-11e8-8505-acde48001122].json ├── redirect[ad029a08-3d81-11e8-9034-acde48001122].json ├── reduceSuccessive[acf87a50-3d81-11e8-b86b-acde48001122].json ├── reduceWhich[ad033e40-3d81-11e8-8051-acde48001122].json ├── reducedFilter[acf923a6-3d81-11e8-8f17-acde48001122].json ├── removeNonASCII[acf95d80-3d81-11e8-b845-acde48001122].json ├── remove[ad031514-3d81-11e8-868a-acde48001122].json ├── reverseString[acfb2d18-3d81-11e8-9f78-acde48001122].json ├── round[acf6ebc2-3d81-11e8-a025-acde48001122].json ├── runAsync[acf7751a-3d81-11e8-8204-acde48001122].json ├── runPromisesInSeries[acfadf66-3d81-11e8-9a3a-acde48001122].json ├── sampleSize[acf617c6-3d81-11e8-afd3-acde48001122].json ├── sample[acf4fe66-3d81-11e8-bba3-acde48001122].json ├── scrollToTop[acf898dc-3d81-11e8-9483-acde48001122].json ├── sdbm[acfbbd9e-3d81-11e8-a9fa-acde48001122].json ├── serializeCookie[ad01fcc6-3d81-11e8-83f8-acde48001122].json ├── setStyle[acff8c46-3d81-11e8-9c9a-acde48001122].json ├── shallowClone[acfa1434-3d81-11e8-b400-acde48001122].json ├── show[acffbc18-3d81-11e8-a802-acde48001122].json ├── shuffle[acf69334-3d81-11e8-a09c-acde48001122].json ├── similarity[acfcc4b6-3d81-11e8-8ce8-acde48001122].json ├── size[ad013386-3d81-11e8-96f7-acde48001122].json ├── sleep[acf43bc0-3d81-11e8-bce3-acde48001122].json ├── smoothScroll[ad037090-3d81-11e8-89d9-acde48001122].json ├── sortCharactersInString[acf54e18-3d81-11e8-81b5-acde48001122].json ├── sortedIndexBy[acfc18f4-3d81-11e8-b548-acde48001122].json ├── sortedIndex[acf9c888-3d81-11e8-a4a1-acde48001122].json ├── sortedLastIndexBy[acf66b02-3d81-11e8-9e20-acde48001122].json ├── sortedLastIndex[ad037fd8-3d81-11e8-9de4-acde48001122].json ├── splitLines[ad01ed4c-3d81-11e8-a3e5-acde48001122].json ├── spreadOver[ad03cc52-3d81-11e8-ba1b-acde48001122].json ├── stableSort[ad004034-3d81-11e8-aba6-acde48001122].json ├── standardDeviation[acfec68a-3d81-11e8-b321-acde48001122].json ├── stringPermutations[acfbdbe6-3d81-11e8-9a4c-acde48001122].json ├── stripHTMLTags[acff7eb8-3d81-11e8-a129-acde48001122].json ├── sumBy[acf3e77e-3d81-11e8-a34b-acde48001122].json ├── sumPower[acfa4718-3d81-11e8-962e-acde48001122].json ├── sum[acf98334-3d81-11e8-b260-acde48001122].json ├── symmetricDifferenceBy[ad022cb4-3d81-11e8-b6a9-acde48001122].json ├── symmetricDifferenceWith[acfba342-3d81-11e8-9dd0-acde48001122].json ├── symmetricDifference[acfc826c-3d81-11e8-a03a-acde48001122].json ├── tail[acfeff10-3d81-11e8-b87f-acde48001122].json ├── takeRightWhile[acf81498-3d81-11e8-a92a-acde48001122].json ├── takeRight[acf5c95e-3d81-11e8-8039-acde48001122].json ├── takeWhile[ad00b3a8-3d81-11e8-aee3-acde48001122].json ├── take[acf3f5de-3d81-11e8-8a21-acde48001122].json ├── throttle[acf76688-3d81-11e8-a049-acde48001122].json ├── timeTaken[acf48d1e-3d81-11e8-913a-acde48001122].json ├── times[ad011674-3d81-11e8-8a29-acde48001122].json ├── toCamelCase[acfa9ac6-3d81-11e8-8114-acde48001122].json ├── toCurrency[ad009bf4-3d81-11e8-b561-acde48001122].json ├── toDecimalMark[acfd72c6-3d81-11e8-b13a-acde48001122].json ├── toKebabCase[ad002ff4-3d81-11e8-a624-acde48001122].json ├── toOrdinalSuffix[ad001030-3d81-11e8-802c-acde48001122].json ├── toSafeInteger[acf3dd74-3d81-11e8-9dc7-acde48001122].json ├── toSnakeCase[acf53586-3d81-11e8-ab76-acde48001122].json ├── toggleClass[acfaf44c-3d81-11e8-a0cb-acde48001122].json ├── tomorrow[acf7f3c8-3d81-11e8-aff1-acde48001122].json ├── transform[acf3a018-3d81-11e8-a6f2-acde48001122].json ├── truncateString[acf8ce68-3d81-11e8-9d1b-acde48001122].json ├── truthCheckCollection[acf6d006-3d81-11e8-b97f-acde48001122].json ├── unary[acf99ae8-3d81-11e8-a58e-acde48001122].json ├── uncurry[ad032ea8-3d81-11e8-8864-acde48001122].json ├── unescapeHTML[acf98e86-3d81-11e8-8300-acde48001122].json ├── unflattenObject[acf4cdec-3d81-11e8-8980-acde48001122].json ├── unfold[ad028f74-3d81-11e8-91d3-acde48001122].json ├── unionBy[acf9d6ca-3d81-11e8-b6eb-acde48001122].json ├── unionWith[ad03a268-3d81-11e8-89f4-acde48001122].json ├── union[acf8a5a2-3d81-11e8-a736-acde48001122].json ├── uniqueElements[acf55c8a-3d81-11e8-b1f9-acde48001122].json ├── untildify[acfe70f4-3d81-11e8-84b2-acde48001122].json ├── unzipWith[acf7e5b8-3d81-11e8-b70b-acde48001122].json ├── unzip[ad02bca4-3d81-11e8-a2a8-acde48001122].json ├── validateNumber[acfe2950-3d81-11e8-925e-acde48001122].json ├── without[acf739ec-3d81-11e8-9e06-acde48001122].json ├── words[acf4be1a-3d81-11e8-9585-acde48001122].json ├── xProd[acf70cb0-3d81-11e8-bb79-acde48001122].json ├── yesNo[acf36a1a-3d81-11e8-ad46-acde48001122].json ├── zipObject[acffaff0-3d81-11e8-836e-acde48001122].json ├── zipWith[acf56ac2-3d81-11e8-abac-acde48001122].json └── zip[acf5f348-3d81-11e8-b9fd-acde48001122].json ├── icon.png └── index.py /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | bower_components 3 | 4 | # docs site 5 | _gh_pages 6 | 7 | # build the extensions 8 | extensions.js 9 | 10 | # deploy the docs 11 | deploy.sh 12 | 13 | # old docs 14 | docs_ 15 | 16 | # check the locale file on README 17 | check.js 18 | 19 | # Common IDE files 20 | nbproject 21 | .~lock.* 22 | .buildpath 23 | .idea 24 | .project 25 | .settings 26 | *.iml 27 | 28 | # OS X Finder internal system files 29 | .DS_Store 30 | .localized 31 | Icon 32 | .vscode 33 | 30-seconds-of-code -------------------------------------------------------------------------------- /3sc.alfredsnippets: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lslvxy/30-seconds-of-code-alfredsnippets/2c1f201ab3c17ed29123e65d8afc9b728c7f2971/3sc.alfredsnippets -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 30-seconds-of-code-alfredsnippets 2 | 30-seconds-of-code.alfredsnippets file which you can then be imported into Alfred 3. 3 | 4 | 5 | [30-seconds-of-code](https://github.com/Chalarangelo/30-seconds-of-code) 6 | 7 | ## DEVELOP 8 | 0. checkout code `git@github.com:lslvxy/30-seconds-of-code-alfredsnippets.git` 9 | 1. checkout `30-seconds-of-code` 10 | ``` 11 | cd 30-seconds-of-code-alfredsnippets 12 | git clone git@github.com:Chalarangelo/30-seconds-of-code.git 13 | ``` 14 | 2. `python3 index.py` 15 | 16 | -------------------------------------------------------------------------------- /dist/JSONToFile[acf4270c-3d81-11e8-ad5b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "JSONToFile", 4 | "dontautoexpand" : true, 5 | "name" : "Writes a JSON object to a file.", 6 | "snippet": "const fs = require('fs');\nconst JSONToFile = (obj, filename) =>\n fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));\n", 7 | "uid": "acf4270c-3d81-11e8-ad5b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/RGBToHex[acfd2636-3d81-11e8-a29e-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "RGBToHex", 4 | "dontautoexpand" : true, 5 | "name" : "Converts the values of RGB components to a color code.", 6 | "snippet": "const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');\n", 7 | "uid": "acfd2636-3d81-11e8-a29e-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/URLJoin[acf9a706-3d81-11e8-943d-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "URLJoin", 4 | "dontautoexpand" : true, 5 | "name" : "Joins all given URL segments together, then normalizes the resulting URL.", 6 | "snippet": "const URLJoin = (...args) =>\n args\n .join('/')\n .replace(/[\/]+/g, '/')\n .replace(/^(.+):\//, '$1://')\n .replace(/^file:/, 'file:/')\n .replace(/\/(\?|&|#[^!])/g, '$1')\n .replace(/\?/g, '&')\n .replace('&', '?');\n", 7 | "uid": "acf9a706-3d81-11e8-943d-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/UUIDGeneratorBrowser[acfd94e8-3d81-11e8-87f6-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "UUIDGeneratorBrowser", 4 | "dontautoexpand" : true, 5 | "name" : "Generates a UUID in a browser.", 6 | "snippet": "const UUIDGeneratorBrowser = () =>\n ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>\n (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)\n );\n", 7 | "uid": "acfd94e8-3d81-11e8-87f6-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/UUIDGeneratorNode[acf49868-3d81-11e8-b868-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "UUIDGeneratorNode", 4 | "dontautoexpand" : true, 5 | "name" : "Generates a UUID in Node.JS.", 6 | "snippet": "const crypto = require('crypto');\nconst UUIDGeneratorNode = () =>\n ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>\n (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)\n );\n", 7 | "uid": "acf49868-3d81-11e8-b868-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/all[ad01a724-3d81-11e8-b745-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "all", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the provided predicate function returns `true` for all elements in a collection, `false` otherwise.", 6 | "snippet": "const all = (arr, fn = Boolean) => arr.every(fn);\n", 7 | "uid": "ad01a724-3d81-11e8-b745-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/any[acfae9b6-3d81-11e8-bc58-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "any", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the provided predicate function returns `true` for at least one element in a collection, `false` otherwise.", 6 | "snippet": "const any = (arr, fn = Boolean) => arr.some(fn);\n", 7 | "uid": "acfae9b6-3d81-11e8-bc58-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/approximatelyEqual[ad01ce70-3d81-11e8-847e-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "approximatelyEqual", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if two numbers are approximately equal to each other.", 6 | "snippet": "const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon;\n", 7 | "uid": "ad01ce70-3d81-11e8-847e-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/arrayToHtmlList[acfa83a4-3d81-11e8-9b27-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "arrayToHtmlList", 4 | "dontautoexpand" : true, 5 | "name" : "Converts the given array elements into `
  • ` tags and appends them to the list of the given id.", 6 | "snippet": "const arrayToHtmlList = (arr, listID) =>\n arr.map(item => (document.querySelector('#' + listID).innerHTML += `
  • ${item}
  • `));\n", 7 | "uid": "acfa83a4-3d81-11e8-9b27-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/ary[acfd07dc-3d81-11e8-9148-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "ary", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a function that accepts up to `n` arguments, ignoring any additional arguments.", 6 | "snippet": "const ary = (fn, n) => (...args) => fn(...args.slice(0, n));\n", 7 | "uid": "acfd07dc-3d81-11e8-9148-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/atob[acf69f28-3d81-11e8-a17d-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "atob", 4 | "dontautoexpand" : true, 5 | "name" : "Decodes a string of data which has been encoded using base-64 encoding.", 6 | "snippet": "const atob = str => new Buffer(str, 'base64').toString('binary');\n", 7 | "uid": "acf69f28-3d81-11e8-a17d-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/attempt[acfe0b8c-3d81-11e8-bfd8-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "attempt", 4 | "dontautoexpand" : true, 5 | "name" : "Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.", 6 | "snippet": "const attempt = (fn, ...args) => {\n try {\n return fn(...args);\n } catch (e) {\n return e instanceof Error ? e : new Error(e);\n }\n};\n", 7 | "uid": "acfe0b8c-3d81-11e8-bfd8-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/averageBy[acf79086-3d81-11e8-a63a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "averageBy", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the average of an array, after mapping each element to a value using the provided function.", 6 | "snippet": "const averageBy = (arr, fn) =>\n arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) /\n arr.length;\n", 7 | "uid": "acf79086-3d81-11e8-a63a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/average[acfa38e8-3d81-11e8-aeaf-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "average", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the average of two or more numbers.", 6 | "snippet": "const average = (...nums) => [...nums].reduce((acc, val) => acc + val, 0) / nums.length;\n", 7 | "uid": "acfa38e8-3d81-11e8-aeaf-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/bifurcateBy[acff5bcc-3d81-11e8-aa99-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "bifurcateBy", 4 | "dontautoexpand" : true, 5 | "name" : "Splits values into two groups according to a predicate function, which specifies which group an element in the input collection belongs to. If the predicate function returns a truthy value, the collection element belongs to the first group; otherwise, it belongs to the second group.", 6 | "snippet": "const bifurcateBy = (arr, fn) =>\n arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]);\n", 7 | "uid": "acff5bcc-3d81-11e8-aa99-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/bifurcate[acfc23e4-3d81-11e8-997b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "bifurcate", 4 | "dontautoexpand" : true, 5 | "name" : "Splits values into two groups. If an element in `filter` is truthy, the corresponding element in the collection belongs to the first group; otherwise, it belongs to the second group.", 6 | "snippet": "const bifurcate = (arr, filter) =>\n arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]);\n", 7 | "uid": "acfc23e4-3d81-11e8-997b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/bindAll[acfc934c-3d81-11e8-8c9f-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "bindAll", 4 | "dontautoexpand" : true, 5 | "name" : "Binds methods of an object to the object itself, overwriting the existing method.", 6 | "snippet": "const bindAll = (obj, ...fns) =>\n fns.forEach(\n fn => (\n (f = obj[fn]),\n (obj[fn] = function() {\n return f.apply(obj);\n })\n )\n );\n", 7 | "uid": "acfc934c-3d81-11e8-8c9f-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/bindKey[acfe569e-3d81-11e8-9f72-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "bindKey", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a function that invokes the method at a given key of an object, optionally adding any additional supplied parameters to the beginning of the arguments.", 6 | "snippet": "const bindKey = (context, fn, ...args) =>\n function() {\n return context[fn].apply(context, args.concat(...arguments));\n };\n", 7 | "uid": "acfe569e-3d81-11e8-9f72-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/bind[acf65cb6-3d81-11e8-a418-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "bind", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a function that invokes `fn` with a given context, optionally adding any additional supplied parameters to the beginning of the arguments.", 6 | "snippet": "const bind = (fn, context, ...args) =>\n function() {\n return fn.apply(context, args.concat(...arguments));\n };\n", 7 | "uid": "acf65cb6-3d81-11e8-a418-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/binomialCoefficient[acfb4938-3d81-11e8-befa-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "binomialCoefficient", 4 | "dontautoexpand" : true, 5 | "name" : "Evaluates the binomial coefficient of two integers `n` and `k`.", 6 | "snippet": "const binomialCoefficient = (n, k) => {\n if (Number.isNaN(n) || Number.isNaN(k)) return NaN;\n if (k < 0 || k > n) return 0;\n if (k === 0 || k === n) return 1;\n if (k === 1 || k === n - 1) return n;\n if (n - k < k) k = n - k;\n let res = n;\n for (let j = 2; j <= k; j++) res *= (n - j + 1) / j;\n return Math.round(res);\n};\n", 7 | "uid": "acfb4938-3d81-11e8-befa-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/bottomVisible[acf3d3b0-3d81-11e8-922d-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "bottomVisible", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the bottom of the page is visible, `false` otherwise.", 6 | "snippet": "const bottomVisible = () =>\n document.documentElement.clientHeight + window.scrollY >=\n (document.documentElement.scrollHeight || document.documentElement.clientHeight);\n", 7 | "uid": "acf3d3b0-3d81-11e8-922d-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/btoa[acfb6436-3d81-11e8-863d-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "btoa", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a base-64 encoded ASCII string from a String object in which each character in the string is treated as a byte of binary data.", 6 | "snippet": "const btoa = str => new Buffer(str, 'binary').toString('base64');\n", 7 | "uid": "acfb6436-3d81-11e8-863d-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/byteSize[acfa2ba2-3d81-11e8-9c49-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "byteSize", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the length of a string in bytes.", 6 | "snippet": "const byteSize = str => new Blob([str]).size;\n", 7 | "uid": "acfa2ba2-3d81-11e8-9c49-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/call[acfa5db6-3d81-11e8-af81-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "call", 4 | "dontautoexpand" : true, 5 | "name" : "Given a key and a set of arguments, call them when given a context. Primarily useful in composition.", 6 | "snippet": "const call = (key, ...args) => context => context[key](...args);\n", 7 | "uid": "acfa5db6-3d81-11e8-af81-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/capitalizeEveryWord[acfc5f94-3d81-11e8-b217-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "capitalizeEveryWord", 4 | "dontautoexpand" : true, 5 | "name" : "Capitalizes the first letter of every word in a string.", 6 | "snippet": "const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());\n", 7 | "uid": "acfc5f94-3d81-11e8-b217-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/capitalize[acf85bd8-3d81-11e8-81da-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "capitalize", 4 | "dontautoexpand" : true, 5 | "name" : "Capitalizes the first letter of a string.", 6 | "snippet": "const capitalize = ([first, ...rest], lowerRest = false) =>\n first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join(''));\n", 7 | "uid": "acf85bd8-3d81-11e8-81da-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/castArray[acfc439c-3d81-11e8-ab77-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "castArray", 4 | "dontautoexpand" : true, 5 | "name" : "Casts the provided value as an array if it's not one.", 6 | "snippet": "const castArray = val => (Array.isArray(val) ? val : [val]);\n", 7 | "uid": "acfc439c-3d81-11e8-ab77-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/chainAsync[acfb9230-3d81-11e8-9cc8-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "chainAsync", 4 | "dontautoexpand" : true, 5 | "name" : "Chains asynchronous functions.", 6 | "snippet": "const chainAsync = fns => {\n let curr = 0;\n const next = () => fns[curr++](next);\n next();\n};\n", 7 | "uid": "acfb9230-3d81-11e8-9cc8-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/chunk[ad014914-3d81-11e8-9094-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "chunk", 4 | "dontautoexpand" : true, 5 | "name" : "Chunks an array into smaller arrays of a specified size.", 6 | "snippet": "const chunk = (arr, size) =>\n Array.from({ length: Math.ceil(arr.length / size) }, (v, i) =>\n arr.slice(i * size, i * size + size)\n );\n", 7 | "uid": "ad014914-3d81-11e8-9094-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/clampNumber[acfc0922-3d81-11e8-841f-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "clampNumber", 4 | "dontautoexpand" : true, 5 | "name" : "Clamps `num` within the inclusive range specified by the boundary values `a` and `b`.", 6 | "snippet": "const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));\n", 7 | "uid": "acfc0922-3d81-11e8-841f-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/cloneRegExp[acf86b50-3d81-11e8-b0be-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "cloneRegExp", 4 | "dontautoexpand" : true, 5 | "name" : "Clones a regular expression.", 6 | "snippet": "const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);\n", 7 | "uid": "acf86b50-3d81-11e8-b0be-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/coalesceFactory[acf7ff76-3d81-11e8-a5e6-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "coalesceFactory", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a customized coalesce function that returns the first argument that returns `true` from the provided argument validation function.", 6 | "snippet": "const coalesceFactory = valid => (...args) => args.find(valid);\n", 7 | "uid": "acf7ff76-3d81-11e8-a5e6-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/coalesce[ad032130-3d81-11e8-ac13-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "coalesce", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the first non-null/undefined argument.", 6 | "snippet": "const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_));\n", 7 | "uid": "ad032130-3d81-11e8-ac13-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/collectInto[ad02dd42-3d81-11e8-84e2-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "collectInto", 4 | "dontautoexpand" : true, 5 | "name" : "Changes a function that accepts an array into a variadic function.", 6 | "snippet": "const collectInto = fn => (...args) => fn(args);\n", 7 | "uid": "ad02dd42-3d81-11e8-84e2-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/colorize[acfaa708-3d81-11e8-88e1-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "colorize", 4 | "dontautoexpand" : true, 5 | "name" : "Add special characters to text to print in color in the console (combined with `console.log()`).", 6 | "snippet": "const colorize = (...args) => ({\n black: `\x1b[30m${args.join(' ')}`,\n red: `\x1b[31m${args.join(' ')}`,\n green: `\x1b[32m${args.join(' ')}`,\n yellow: `\x1b[33m${args.join(' ')}`,\n blue: `\x1b[34m${args.join(' ')}`,\n magenta: `\x1b[35m${args.join(' ')}`,\n cyan: `\x1b[36m${args.join(' ')}`,\n white: `\x1b[37m${args.join(' ')}`,\n bgBlack: `\x1b[40m${args.join(' ')}\x1b[0m`,\n bgRed: `\x1b[41m${args.join(' ')}\x1b[0m`,\n bgGreen: `\x1b[42m${args.join(' ')}\x1b[0m`,\n bgYellow: `\x1b[43m${args.join(' ')}\x1b[0m`,\n bgBlue: `\x1b[44m${args.join(' ')}\x1b[0m`,\n bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`,\n bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`,\n bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m`\n});\n", 7 | "uid": "acfaa708-3d81-11e8-88e1-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/compact[ad00ff7a-3d81-11e8-8061-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "compact", 4 | "dontautoexpand" : true, 5 | "name" : "Removes falsey values from an array.", 6 | "snippet": "const compact = arr => arr.filter(Boolean);\n", 7 | "uid": "ad00ff7a-3d81-11e8-8061-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/composeRight[acfd16fa-3d81-11e8-bc26-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "composeRight", 4 | "dontautoexpand" : true, 5 | "name" : "Performs left-to-right function composition.", 6 | "snippet": "const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));\n", 7 | "uid": "acfd16fa-3d81-11e8-bc26-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/compose[acfcae5e-3d81-11e8-ab18-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "compose", 4 | "dontautoexpand" : true, 5 | "name" : "Performs right-to-left function composition.", 6 | "snippet": "const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));\n", 7 | "uid": "acfcae5e-3d81-11e8-ab18-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/converge[acfa07e4-3d81-11e8-89b9-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "converge", 4 | "dontautoexpand" : true, 5 | "name" : "Accepts a converging function and a list of branching functions and returns a function that applies each branching function to the arguments and the results of the branching functions are passed as arguments to the converging function.", 6 | "snippet": "const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args)));\n", 7 | "uid": "acfa07e4-3d81-11e8-89b9-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/copyToClipboard[ad008dee-3d81-11e8-bc5c-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "copyToClipboard", 4 | "dontautoexpand" : true, 5 | "name" : "⚠️ **NOTICE:** The same functionality can be easily implemented by using the new asynchronous Clipboard API, which is still experimental but should be used in the future instead of this snippet. Find out more about it [here](https://github.com/w3c/clipboard-apis/blob/master/explainer.adoc#writing-to-the-clipboard).", 6 | "snippet": "const copyToClipboard = str => {\n const el = document.createElement('textarea');\n el.value = str;\n el.setAttribute('readonly', '');\n el.style.position = 'absolute';\n el.style.left = '-9999px';\n document.body.appendChild(el);\n const selected =\n document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false;\n el.select();\n document.execCommand('copy');\n document.body.removeChild(el);\n if (selected) {\n document.getSelection().removeAllRanges();\n document.getSelection().addRange(selected);\n }\n};\n", 7 | "uid": "ad008dee-3d81-11e8-bc5c-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/countBy[acf4a77a-3d81-11e8-b53a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "countBy", 4 | "dontautoexpand" : true, 5 | "name" : "Groups the elements of an array based on the given function and returns the count of elements in each group.", 6 | "snippet": "const countBy = (arr, fn) =>\n arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => {\n acc[val] = (acc[val] || 0) + 1;\n return acc;\n }, {});\n", 7 | "uid": "acf4a77a-3d81-11e8-b53a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/countOccurrences[acf83f5e-3d81-11e8-8159-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "countOccurrences", 4 | "dontautoexpand" : true, 5 | "name" : "Counts the occurrences of a value in an array.", 6 | "snippet": "const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a + 0), 0);\n", 7 | "uid": "acf83f5e-3d81-11e8-8159-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/createElement[ad02ef62-3d81-11e8-9c4d-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "createElement", 4 | "dontautoexpand" : true, 5 | "name" : "Creates an element from a string (without appending it to the document). ", 6 | "snippet": "const createElement = str => {\n const el = document.createElement('div');\n el.innerHTML = str;\n return el.firstElementChild;\n};\n", 7 | "uid": "ad02ef62-3d81-11e8-9c4d-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/createEventHub[acfbf7ca-3d81-11e8-b114-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "createEventHub", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a pub/sub ([publish–subscribe](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern)) event hub with `emit`, `on`, and `off` methods.", 6 | "snippet": "const createEventHub = () => ({\n hub: Object.create(null),\n emit(event, data) {\n (this.hub[event] || []).forEach(handler => handler(data));\n },\n on(event, handler) {\n if (!this.hub[event]) this.hub[event] = [];\n this.hub[event].push(handler);\n },\n off(event, handler) {\n const i = (this.hub[event] || []).findIndex(h => h === handler);\n if (i > -1) this.hub[event].splice(i, 1);\n }\n});\n", 7 | "uid": "acfbf7ca-3d81-11e8-b114-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/currentURL[acfe38e6-3d81-11e8-b54d-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "currentURL", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the current URL.", 6 | "snippet": "const currentURL = () => window.location.href;\n", 7 | "uid": "acfe38e6-3d81-11e8-b54d-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/curry[acf431ac-3d81-11e8-8f53-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "curry", 4 | "dontautoexpand" : true, 5 | "name" : "Curries a function.", 6 | "snippet": "const curry = (fn, arity = fn.length, ...args) =>\n arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);\n", 7 | "uid": "acf431ac-3d81-11e8-8f53-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/debounce[acfad430-3d81-11e8-a8a5-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "debounce", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a debounced function that delays invoking the provided function until at least `ms` milliseconds have elapsed since the last time it was invoked.", 6 | "snippet": "const debounce = (fn, ms = 0) => {\n let timeoutId;\n return function(...args) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => fn.apply(this, args), ms);\n };\n};\n", 7 | "uid": "acfad430-3d81-11e8-a8a5-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/decapitalize[ad021ce8-3d81-11e8-896a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "decapitalize", 4 | "dontautoexpand" : true, 5 | "name" : "Decapitalizes the first letter of a string.", 6 | "snippet": "const decapitalize = ([first, ...rest], upperRest = false) =>\n first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join(''));\n", 7 | "uid": "ad021ce8-3d81-11e8-896a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/deepClone[acf5a958-3d81-11e8-ac2f-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "deepClone", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a deep clone of an object.", 6 | "snippet": "const deepClone = obj => {\n let clone = Object.assign({}, obj);\n Object.keys(clone).forEach(\n key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key])\n );\n return clone;\n};\n", 7 | "uid": "acf5a958-3d81-11e8-ac2f-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/deepFlatten[ad03af42-3d81-11e8-af3c-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "deepFlatten", 4 | "dontautoexpand" : true, 5 | "name" : "Deep flattens an array.", 6 | "snippet": "const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v)));\n", 7 | "uid": "ad03af42-3d81-11e8-af3c-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/defaults[acf4541e-3d81-11e8-abd0-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "defaults", 4 | "dontautoexpand" : true, 5 | "name" : "Assigns default values for all properties in an object that are `undefined`.", 6 | "snippet": "const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);\n", 7 | "uid": "acf4541e-3d81-11e8-abd0-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/defer[acf3be8c-3d81-11e8-858f-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "defer", 4 | "dontautoexpand" : true, 5 | "name" : "Defers invoking a function until the current call stack has cleared.", 6 | "snippet": "const defer = (fn, ...args) => setTimeout(fn, 1, ...args);\n", 7 | "uid": "acf3be8c-3d81-11e8-858f-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/degreesToRads[acf72b50-3d81-11e8-a163-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "degreesToRads", 4 | "dontautoexpand" : true, 5 | "name" : "Converts an angle from degrees to radians.", 6 | "snippet": "const degreesToRads = deg => deg * Math.PI / 180.0;\n", 7 | "uid": "acf72b50-3d81-11e8-a163-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/delay[acf4133e-3d81-11e8-9892-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "delay", 4 | "dontautoexpand" : true, 5 | "name" : "Invokes the provided function after `wait` milliseconds.", 6 | "snippet": "const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args);\n", 7 | "uid": "acf4133e-3d81-11e8-9892-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/detectDeviceType[acf92fd8-3d81-11e8-a9b8-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "detectDeviceType", 4 | "dontautoexpand" : true, 5 | "name" : "Detects wether the website is being opened in a mobile device or a desktop/laptop.", 6 | "snippet": "const detectDeviceType = () =>\n /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)\n ? 'Mobile'\n : 'Desktop';\n", 7 | "uid": "acf92fd8-3d81-11e8-a9b8-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/differenceBy[acf60798-3d81-11e8-b644-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "differenceBy", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the difference between two arrays, after applying the provided function to each array element of both.", 6 | "snippet": "const differenceBy = (a, b, fn) => {\n const s = new Set(b.map(v => fn(v)));\n return a.filter(x => !s.has(fn(x)));\n};\n", 7 | "uid": "acf60798-3d81-11e8-b644-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/differenceWith[acf3aa34-3d81-11e8-8e28-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "differenceWith", 4 | "dontautoexpand" : true, 5 | "name" : "Filters out all values from an array for which the comparator function does not return `true`.", 6 | "snippet": "const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1);\n", 7 | "uid": "acf3aa34-3d81-11e8-8e28-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/difference[acfca33a-3d81-11e8-91da-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "difference", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the difference between two arrays.", 6 | "snippet": "const difference = (a, b) => {\n const s = new Set(b);\n return a.filter(x => !s.has(x));\n};\n", 7 | "uid": "acfca33a-3d81-11e8-91da-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/digitize[acfab786-3d81-11e8-82b4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "digitize", 4 | "dontautoexpand" : true, 5 | "name" : "Converts a number to an array of digits.", 6 | "snippet": "const digitize = n => [...`${n}`].map(i => parseInt(i));\n", 7 | "uid": "acfab786-3d81-11e8-82b4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/distance[ad013e62-3d81-11e8-80c4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "distance", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the distance between two points.", 6 | "snippet": "const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0);\n", 7 | "uid": "ad013e62-3d81-11e8-80c4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/dropRightWhile[acf68418-3d81-11e8-b9e5-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "dropRightWhile", 4 | "dontautoexpand" : true, 5 | "name" : "Removes elements from the end of an array until the passed function returns `true`. Returns the remaining elements in the array.", 6 | "snippet": "const dropRightWhile = (arr, func) => {\n while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1);\n return arr;\n};\n", 7 | "uid": "acf68418-3d81-11e8-b9e5-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/dropRight[acf5bdc6-3d81-11e8-93f3-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "dropRight", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a new array with `n` elements removed from the right.", 6 | "snippet": "const dropRight = (arr, n = 1) => arr.slice(0, -n);\n", 7 | "uid": "acf5bdc6-3d81-11e8-93f3-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/dropWhile[ad00be40-3d81-11e8-b7a6-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "dropWhile", 4 | "dontautoexpand" : true, 5 | "name" : "Removes elements in an array until the passed function returns `true`. Returns the remaining elements in the array.", 6 | "snippet": "const dropWhile = (arr, func) => {\n while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1);\n return arr;\n};\n", 7 | "uid": "ad00be40-3d81-11e8-b7a6-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/drop[acf8e56c-3d81-11e8-9648-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "drop", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a new array with `n` elements removed from the left.", 6 | "snippet": "const drop = (arr, n = 1) => arr.slice(n);\n", 7 | "uid": "acf8e56c-3d81-11e8-9648-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/elementIsVisibleInViewport[ad005a7a-3d81-11e8-98c8-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "elementIsVisibleInViewport", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the element specified is visible in the viewport, `false` otherwise.", 6 | "snippet": "const elementIsVisibleInViewport = (el, partiallyVisible = false) => {\n const { top, left, bottom, right } = el.getBoundingClientRect();\n const { innerHeight, innerWidth } = window;\n return partiallyVisible\n ? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) &&\n ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))\n : top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;\n};\n", 7 | "uid": "ad005a7a-3d81-11e8-98c8-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/elo[acfda534-3d81-11e8-ade4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "elo", 4 | "dontautoexpand" : true, 5 | "name" : "Computes the new ratings between two or more opponents using the [Elo rating system](https://en.wikipedia.org/wiki/Elo_rating_system). It takes an array", 6 | "snippet": "const elo = ([...ratings], kFactor = 32, selfRating) => {\n const [a, b] = ratings;\n const expectedScore = (self, opponent) => 1 / (1 + 10 ** ((opponent - self) / 400));\n const newRating = (rating, i) =>\n (selfRating || rating) + kFactor * (i - expectedScore(i ? a : b, i ? b : a));\n if (ratings.length === 2) {\n return [newRating(a, 1), newRating(b, 0)];\n } else {\n for (let i = 0; i < ratings.length; i++) {\n let j = i;\n while (j < ratings.length - 1) {\n [ratings[i], ratings[j + 1]] = elo([ratings[i], ratings[j + 1]], kFactor);\n j++;\n }\n }\n }\n return ratings;\n};\n", 7 | "uid": "acfda534-3d81-11e8-ade4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/equals[acfde562-3d81-11e8-b4a6-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "equals", 4 | "dontautoexpand" : true, 5 | "name" : "Performs a deep comparison between two values to determine if they are equivalent.", 6 | "snippet": "const equals = (a, b) => {\n if (a === b) return true;\n if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime();\n if (!a || !b || (typeof a != 'object' && typeof b !== 'object')) return a === b;\n if (a === null || a === undefined || b === null || b === undefined) return false;\n if (a.prototype !== b.prototype) return false;\n let keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every(k => equals(a[k], b[k]));\n};\n", 7 | "uid": "acfde562-3d81-11e8-b4a6-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/escapeHTML[acfcb87a-3d81-11e8-a2a9-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "escapeHTML", 4 | "dontautoexpand" : true, 5 | "name" : "Escapes a string for use in HTML.", 6 | "snippet": "const escapeHTML = str =>\n str.replace(\n /[&<>'\"]/g,\n tag =>\n ({\n '&': '&',\n '<': '<',\n '>': '>',\n \"'\": ''',\n '\"': '"'\n }[tag] || tag)\n );\n", 7 | "uid": "acfcb87a-3d81-11e8-a2a9-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/escapeRegExp[acf5d750-3d81-11e8-a438-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "escapeRegExp", 4 | "dontautoexpand" : true, 5 | "name" : "Escapes a string to use in a regular expression.", 6 | "snippet": "const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');\n", 7 | "uid": "acf5d750-3d81-11e8-a438-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/everyNth[acf8ba62-3d81-11e8-a2d0-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "everyNth", 4 | "dontautoexpand" : true, 5 | "name" : "Returns every nth element in an array.", 6 | "snippet": "const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1);\n", 7 | "uid": "acf8ba62-3d81-11e8-a2d0-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/extendHex[acf79b46-3d81-11e8-852e-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "extendHex", 4 | "dontautoexpand" : true, 5 | "name" : "Extends a 3-digit color code to a 6-digit color code.", 6 | "snippet": "const extendHex = shortHex =>\n '#' +\n shortHex\n .slice(shortHex.startsWith('#') ? 1 : 0)\n .split('')\n .map(x => x + x)\n .join('');\n", 7 | "uid": "acf79b46-3d81-11e8-852e-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/factorial[acf54092-3d81-11e8-8caa-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "factorial", 4 | "dontautoexpand" : true, 5 | "name" : "Calculates the factorial of a number.", 6 | "snippet": "const factorial = n =>\n n < 0\n ? (() => {\n throw new TypeError('Negative numbers are not allowed!');\n })()\n : n <= 1 ? 1 : n * factorial(n - 1);\n", 7 | "uid": "acf54092-3d81-11e8-8caa-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/fibonacci[acf7bfca-3d81-11e8-814d-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "fibonacci", 4 | "dontautoexpand" : true, 5 | "name" : "Generates an array, containing the Fibonacci sequence, up until the nth term.", 6 | "snippet": "const fibonacci = n =>\n Array.from({ length: n }).reduce(\n (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),\n []\n );\n", 7 | "uid": "acf7bfca-3d81-11e8-814d-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/filterNonUnique[ad02af48-3d81-11e8-8de3-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "filterNonUnique", 4 | "dontautoexpand" : true, 5 | "name" : "Filters out the non-unique values in an array.", 6 | "snippet": "const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));\n", 7 | "uid": "ad02af48-3d81-11e8-8de3-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/findKey[acfac878-3d81-11e8-8ffe-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "findKey", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the first key that satisfies the provided testing function. Otherwise `undefined` is returned.", 6 | "snippet": "const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj));\n", 7 | "uid": "acfac878-3d81-11e8-8ffe-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/findLastIndex[acfce11c-3d81-11e8-8f3b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "findLastIndex", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the index of the last element for which the provided function returns a truthy value.", 6 | "snippet": "const findLastIndex = (arr, fn) =>\n arr\n .map((val, i) => [i, val])\n .filter(val => fn(val[1], val[0], arr))\n .slice(-1)[0][0];\n", 7 | "uid": "acfce11c-3d81-11e8-8f3b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/findLastKey[acf3814c-3d81-11e8-addc-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "findLastKey", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the last key that satisfies the provided testing function. Otherwise `undefined` is returned.", 6 | "snippet": "const findLastKey = (obj, fn) =>\n Object.keys(obj)\n .reverse()\n .find(key => fn(obj[key], key, obj));\n", 7 | "uid": "acf3814c-3d81-11e8-addc-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/findLast[ad012452-3d81-11e8-a44b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "findLast", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the last element for which the provided function returns a truthy value.", 6 | "snippet": "const findLast = (arr, fn) => arr.filter(fn).slice(-1)[0];\n", 7 | "uid": "ad012452-3d81-11e8-a44b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/flattenObject[acfd325c-3d81-11e8-bb79-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "flattenObject", 4 | "dontautoexpand" : true, 5 | "name" : "Flatten an object with the paths for keys.", 6 | "snippet": "const flattenObject = (obj, prefix = '') =>\n Object.keys(obj).reduce((acc, k) => {\n const pre = prefix.length ? prefix + '.' : '';\n if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k));\n else acc[pre + k] = obj[k];\n return acc;\n }, {});\n", 7 | "uid": "acfd325c-3d81-11e8-bb79-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/flatten[acfb8452-3d81-11e8-8094-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "flatten", 4 | "dontautoexpand" : true, 5 | "name" : "Flattens an array up to the specified depth.", 6 | "snippet": "const flatten = (arr, depth = 1) =>\n arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []);\n", 7 | "uid": "acfb8452-3d81-11e8-8094-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/flip[acf473ec-3d81-11e8-8782-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "flip", 4 | "dontautoexpand" : true, 5 | "name" : "Flip takes a function as an argument, then makes the first argument the last.", 6 | "snippet": "const flip = fn => (first, ...rest) => fn(...rest, first);\n", 7 | "uid": "acf473ec-3d81-11e8-8782-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/forEachRight[acf9fa2e-3d81-11e8-ba3b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "forEachRight", 4 | "dontautoexpand" : true, 5 | "name" : "Executes a provided function once for each array element, starting from the array's last element.", 6 | "snippet": "const forEachRight = (arr, callback) =>\n arr\n .slice(0)\n .reverse()\n .forEach(callback);\n", 7 | "uid": "acf9fa2e-3d81-11e8-ba3b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/forOwnRight[acfb1b34-3d81-11e8-87f4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "forOwnRight", 4 | "dontautoexpand" : true, 5 | "name" : "Iterates over all own properties of an object in reverse, running a callback for each one.", 6 | "snippet": "const forOwnRight = (obj, fn) =>\n Object.keys(obj)\n .reverse()\n .forEach(key => fn(obj[key], key, obj));\n", 7 | "uid": "acfb1b34-3d81-11e8-87f4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/forOwn[ad019842-3d81-11e8-8eee-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "forOwn", 4 | "dontautoexpand" : true, 5 | "name" : "Iterates over all own properties of an object, running a callback for each one.", 6 | "snippet": "const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));\n", 7 | "uid": "ad019842-3d81-11e8-8eee-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/formatDuration[acf96910-3d81-11e8-af5b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "formatDuration", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the human readable format of the given number of milliseconds.", 6 | "snippet": "const formatDuration = ms => {\n if (ms < 0) ms = -ms;\n const time = {\n day: Math.floor(ms / 86400000),\n hour: Math.floor(ms / 3600000) % 24,\n minute: Math.floor(ms / 60000) % 60,\n second: Math.floor(ms / 1000) % 60,\n millisecond: Math.floor(ms) % 1000\n };\n return Object.entries(time)\n .filter(val => val[1] !== 0)\n .map(val => val[1] + ' ' + (val[1] !== 1 ? val[0] + 's' : val[0]))\n .join(', ');\n};\n", 7 | "uid": "acf96910-3d81-11e8-af5b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/fromCamelCase[acff6c1e-3d81-11e8-a7d1-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "fromCamelCase", 4 | "dontautoexpand" : true, 5 | "name" : "Converts a string from camelcase.", 6 | "snippet": "const fromCamelCase = (str, separator = '_') =>\n str\n .replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')\n .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2')\n .toLowerCase();\n", 7 | "uid": "acff6c1e-3d81-11e8-a7d1-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/functionName[acfa1ec8-3d81-11e8-a016-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "functionName", 4 | "dontautoexpand" : true, 5 | "name" : "Logs the name of a function.", 6 | "snippet": "const functionName = fn => (console.debug(fn.name), fn);\n", 7 | "uid": "acfa1ec8-3d81-11e8-a016-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/functions[acfdda18-3d81-11e8-94ff-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "functions", 4 | "dontautoexpand" : true, 5 | "name" : "Returns an array of function property names from own (and optionally inherited) enumerable properties of an object.", 6 | "snippet": "const functions = (obj, inherited = false) =>\n (inherited\n ? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))]\n : Object.keys(obj)\n ).filter(key => typeof obj[key] === 'function');\n", 7 | "uid": "acfdda18-3d81-11e8-94ff-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/gcd[ad03c074-3d81-11e8-a2ca-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "gcd", 4 | "dontautoexpand" : true, 5 | "name" : "Calculates the greatest common divisor between two or more numbers/arrays.", 6 | "snippet": "const gcd = (...arr) => {\n const _gcd = (x, y) => (!y ? x : gcd(y, x % y));\n return [...arr].reduce((a, b) => _gcd(a, b));\n};\n", 7 | "uid": "ad03c074-3d81-11e8-a2ca-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/geometricProgression[ad004e58-3d81-11e8-82fd-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "geometricProgression", 4 | "dontautoexpand" : true, 5 | "name" : "Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive and the ratio between two terms is `step`.", 6 | "snippet": "const geometricProgression = (end, start = 1, step = 2) =>\n Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(\n (v, i) => start * step ** i\n );\n", 7 | "uid": "ad004e58-3d81-11e8-82fd-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/getColonTimeFromDate[ad0153b4-3d81-11e8-a042-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "getColonTimeFromDate", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a string of the form `HH:MM:SS` from a `Date` object.", 6 | "snippet": "const getColonTimeFromDate = date => date.toTimeString().slice(0, 8);\n", 7 | "uid": "ad0153b4-3d81-11e8-a042-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/getDaysDiffBetweenDates[acf9effa-3d81-11e8-ac2a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "getDaysDiffBetweenDates", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the difference (in days) between two dates.", 6 | "snippet": "const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>\n (dateFinal - dateInitial) / (1000 * 3600 * 24);\n", 7 | "uid": "acf9effa-3d81-11e8-ac2a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/getMeridiemSuffixOfInteger[ad0309c0-3d81-11e8-a5f2-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "getMeridiemSuffixOfInteger", 4 | "dontautoexpand" : true, 5 | "name" : "Converts an integer to a suffixed string, adding `am` or `pm` based on its value.", 6 | "snippet": "const getMeridiemSuffixOfInteger = num =>\n num === 0 || num === 24\n ? 12 + 'am'\n : num === 12 ? 12 + 'pm' : num < 12 ? num % 12 + 'am' : num % 12 + 'pm';\n", 7 | "uid": "ad0309c0-3d81-11e8-a5f2-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/getScrollPosition[acf78528-3d81-11e8-99e0-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "getScrollPosition", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the scroll position of the current page.", 6 | "snippet": "const getScrollPosition = (el = window) => ({\n x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft,\n y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop\n});\n", 7 | "uid": "acf78528-3d81-11e8-99e0-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/getStyle[ad0350c6-3d81-11e8-b820-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "getStyle", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the value of a CSS rule for the specified element.", 6 | "snippet": "const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName];\n", 7 | "uid": "ad0350c6-3d81-11e8-b820-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/getType[acf7cbb4-3d81-11e8-82fe-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "getType", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the native type of a value.", 6 | "snippet": "const getType = v =>\n v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase();\n", 7 | "uid": "acf7cbb4-3d81-11e8-82fe-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/getURLParameters[acfe4874-3d81-11e8-85a3-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "getURLParameters", 4 | "dontautoexpand" : true, 5 | "name" : "Returns an object containing the parameters of the current URL.", 6 | "snippet": "const getURLParameters = url =>\n (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce(\n (a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a),\n {}\n );\n", 7 | "uid": "acfe4874-3d81-11e8-85a3-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/get[acf7afc6-3d81-11e8-b656-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "get", 4 | "dontautoexpand" : true, 5 | "name" : "Retrieve a set of properties indicated by the given selectors from an object.", 6 | "snippet": "const get = (from, ...selectors) =>\n [...selectors].map(s =>\n s\n .replace(/\[([^\[\]]*)\]/g, '.$1.')\n .split('.')\n .filter(t => t !== '')\n .reduce((prev, cur) => prev && prev[cur], from)\n );\n", 7 | "uid": "acf7afc6-3d81-11e8-b656-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/groupBy[acf80a1e-3d81-11e8-8463-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "groupBy", 4 | "dontautoexpand" : true, 5 | "name" : "Groups the elements of an array based on the given function.", 6 | "snippet": "const groupBy = (arr, fn) =>\n arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => {\n acc[val] = (acc[val] || []).concat(arr[i]);\n return acc;\n }, {});\n", 7 | "uid": "acf80a1e-3d81-11e8-8463-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/hammingDistance[ad00a868-3d81-11e8-bd6e-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "hammingDistance", 4 | "dontautoexpand" : true, 5 | "name" : "Calculates the Hamming distance between two values.", 6 | "snippet": "const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length;\n", 7 | "uid": "ad00a868-3d81-11e8-bd6e-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/hasClass[acff13ba-3d81-11e8-a5f1-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "hasClass", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the element has the specified class, `false` otherwise.", 6 | "snippet": "const hasClass = (el, className) => el.classList.contains(className);\n", 7 | "uid": "acff13ba-3d81-11e8-a5f1-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/hasFlags[acf916e2-3d81-11e8-816a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "hasFlags", 4 | "dontautoexpand" : true, 5 | "name" : "Check if the current process's arguments contain the specified flags.", 6 | "snippet": "const hasFlags = (...flags) =>\n flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag));\n", 7 | "uid": "acf916e2-3d81-11e8-816a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/hashBrowser[acffa26c-3d81-11e8-b059-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "hashBrowser", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a hash for a value using the [SHA-256](https://en.wikipedia.org/wiki/SHA-2) algorithm. Returns a promise.", 6 | "snippet": "const hashBrowser = val =>\n crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(h => {\n let hexes = [],\n view = new DataView(h);\n for (let i = 0; i < view.byteLength; i += 4)\n hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8));\n return hexes.join('');\n });\n", 7 | "uid": "acffa26c-3d81-11e8-b059-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/hashNode[ad026d76-3d81-11e8-a366-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "hashNode", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a hash for a value using the [SHA-256](https://en.wikipedia.org/wiki/SHA-2) algorithm. Returns a promise.", 6 | "snippet": "const crypto = require('crypto');\nconst hashNode = val =>\n new Promise(resolve =>\n setTimeout(\n () =>\n resolve(\n crypto\n .createHash('sha256')\n .update(val)\n .digest('hex')\n ),\n 0\n )\n );\n", 7 | "uid": "ad026d76-3d81-11e8-a366-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/head[acf37712-3d81-11e8-b816-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "head", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the head of a list.", 6 | "snippet": "const head = arr => arr[0];\n", 7 | "uid": "acf37712-3d81-11e8-b816-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/hexToRGB[acf45e18-3d81-11e8-9c41-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "hexToRGB", 4 | "dontautoexpand" : true, 5 | "name" : "Converts a color code to a `rgb()` or `rgba()` string if alpha value is provided.", 6 | "snippet": "const hexToRGB = hex => {\n let alpha = false,\n h = hex.slice(hex.startsWith('#') ? 1 : 0);\n if (h.length === 3) h = [...h].map(x => x + x).join('');\n else if (h.length === 8) alpha = true;\n h = parseInt(h, 16);\n return (\n 'rgb' +\n (alpha ? 'a' : '') +\n '(' +\n (h >>> (alpha ? 24 : 16)) +\n ', ' +\n ((h & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8)) +\n ', ' +\n ((h & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0)) +\n (alpha ? `, ${h & 0x000000ff}` : '') +\n ')'\n );\n};\n", 7 | "uid": "acf45e18-3d81-11e8-9c41-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/hide[acf449da-3d81-11e8-8a30-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "hide", 4 | "dontautoexpand" : true, 5 | "name" : "Hides all the elements specified.", 6 | "snippet": "const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));\n", 7 | "uid": "acf449da-3d81-11e8-8a30-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/httpGet[acfeaa74-3d81-11e8-b787-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "httpGet", 4 | "dontautoexpand" : true, 5 | "name" : "Makes a `GET` request to the passed URL.", 6 | "snippet": "const httpGet = (url, callback, err = console.error) => {\n const request = new XMLHttpRequest();\n request.open('GET', url, true);\n request.onload = () => callback(request.responseText);\n request.onerror = () => err(request);\n request.send();\n};\n", 7 | "uid": "acfeaa74-3d81-11e8-b787-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/httpPost[acfcf6ac-3d81-11e8-90a0-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "httpPost", 4 | "dontautoexpand" : true, 5 | "name" : "Makes a `POST` request to the passed URL.", 6 | "snippet": "const httpPost = (url, data, callback, err = console.error) => {\n const request = new XMLHttpRequest();\n request.open('POST', url, true);\n request.setRequestHeader('Content-type', 'application/json; charset=utf-8');\n request.onload = () => callback(request.responseText);\n request.onerror = () => err(request);\n request.send(data);\n};\n", 7 | "uid": "acfcf6ac-3d81-11e8-90a0-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/httpsRedirect[acf631dc-3d81-11e8-8a8d-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "httpsRedirect", 4 | "dontautoexpand" : true, 5 | "name" : "Redirects the page to HTTPS if its currently in HTTP. Also, pressing the back button doesn't take it back to the HTTP page as its replaced in the history.", 6 | "snippet": "const httpsRedirect = () => {\n if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]);\n};\n", 7 | "uid": "acf631dc-3d81-11e8-8a8d-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/inRange[acfbb08a-3d81-11e8-bcd8-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "inRange", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the given number falls within the given range.", 6 | "snippet": "const inRange = (n, start, end = null) => {\n if (end && start > end) end = [start, (start = end)][0];\n return end == null ? n >= 0 && n < start : n >= start && n < end;\n};\n", 7 | "uid": "acfbb08a-3d81-11e8-bcd8-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/indexOfAll[acfa792c-3d81-11e8-84da-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "indexOfAll", 4 | "dontautoexpand" : true, 5 | "name" : "Returns all indices of `val` in an array. If `val` never occurs, returns `[]`.", 6 | "snippet": "const indexOfAll = (arr, val) => {\n const indices = [];\n arr.forEach((el, i) => el === val && indices.push(i));\n return indices;\n};\n", 7 | "uid": "acfa792c-3d81-11e8-84da-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/initial[acf58a48-3d81-11e8-af88-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "initial", 4 | "dontautoexpand" : true, 5 | "name" : "Returns all the elements of an array except the last one.", 6 | "snippet": "const initial = arr => arr.slice(0, -1);\n", 7 | "uid": "acf58a48-3d81-11e8-af88-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/initialize2DArray[ad00000c-3d81-11e8-8f52-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "initialize2DArray", 4 | "dontautoexpand" : true, 5 | "name" : "Initializes a 2D array of given width and height and value.", 6 | "snippet": "const initialize2DArray = (w, h, val = null) =>\n Array.from({ length: h }).map(() => Array.from({ length: w }).fill(val));\n", 7 | "uid": "ad00000c-3d81-11e8-8f52-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/initializeArrayWithRangeRight[ad00dd62-3d81-11e8-bef2-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "initializeArrayWithRangeRight", 4 | "dontautoexpand" : true, 5 | "name" : "Initializes an array containing the numbers in the specified range (in reverse) where `start` and `end` are inclusive with their common difference `step`.", 6 | "snippet": "const initializeArrayWithRangeRight = (end, start = 0, step = 1) =>\n Array.from({ length: Math.ceil((end + 1 - start) / step) }).map(\n (v, i, arr) => (arr.length - i - 1) * step + start\n );\n", 7 | "uid": "ad00dd62-3d81-11e8-bef2-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/initializeArrayWithRange[acff452e-3d81-11e8-91f4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "initializeArrayWithRange", 4 | "dontautoexpand" : true, 5 | "name" : "Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive with their common difference `step`.", 6 | "snippet": "const initializeArrayWithRange = (end, start = 0, step = 1) =>\n Array.from({ length: Math.ceil((end + 1 - start) / step) }).map((v, i) => i * step + start);\n", 7 | "uid": "acff452e-3d81-11e8-91f4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/initializeArrayWithValues[acfa8ed0-3d81-11e8-b3de-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "initializeArrayWithValues", 4 | "dontautoexpand" : true, 5 | "name" : "Initializes and fills an array with the specified values.", 6 | "snippet": "const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val);\n", 7 | "uid": "acfa8ed0-3d81-11e8-b3de-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/intersectionBy[acffd798-3d81-11e8-90f4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "intersectionBy", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a list of elements that exist in both arrays, after applying the provided function to each array element of both.", 6 | "snippet": "const intersectionBy = (a, b, fn) => {\n const s = new Set(b.map(x => fn(x)));\n return a.filter(x => s.has(fn(x)));\n};\n", 7 | "uid": "acffd798-3d81-11e8-90f4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/intersectionWith[acf6b562-3d81-11e8-9019-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "intersectionWith", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a list of elements that exist in both arrays, using a provided comparator function.", 6 | "snippet": "const intersectionWith = (a, b, comp) => a.filter(x => b.findIndex(y => comp(x, y)) !== -1);\n", 7 | "uid": "acf6b562-3d81-11e8-9019-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/intersection[acfa6e1e-3d81-11e8-85be-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "intersection", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a list of elements that exist in both arrays.", 6 | "snippet": "const intersection = (a, b) => {\n const s = new Set(b);\n return a.filter(x => s.has(x));\n};\n", 7 | "uid": "acfa6e1e-3d81-11e8-85be-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/invertKeyValues[acf82f98-3d81-11e8-84d5-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "invertKeyValues", 4 | "dontautoexpand" : true, 5 | "name" : "Inverts the key-value pairs of an object, without mutating it. The corresponding inverted value of each inverted key is an array of keys responsible for generating the inverted value. If a function is supplied, it is applied to each inverted key.", 6 | "snippet": "const invertKeyValues = (obj, fn) =>\n Object.keys(obj).reduce((acc, key) => {\n const val = fn ? fn(obj[key]) : obj[key];\n acc[val] = acc[val] || [];\n acc[val].push(key);\n return acc;\n }, {});\n", 7 | "uid": "acf82f98-3d81-11e8-84d5-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isAbsoluteURL[ad002018-3d81-11e8-92b8-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isAbsoluteURL", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the given string is an absolute URL, `false` otherwise.", 6 | "snippet": "const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str);\n", 7 | "uid": "ad002018-3d81-11e8-92b8-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isAnagram[acf4ed18-3d81-11e8-8db6-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isAnagram", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).", 6 | "snippet": "const isAnagram = (str1, str2) => {\n const normalize = str =>\n str\n .toLowerCase()\n .replace(/[^a-z0-9]/gi, '')\n .split('')\n .sort()\n .join('');\n return normalize(str1) === normalize(str2);\n};\n", 7 | "uid": "acf4ed18-3d81-11e8-8db6-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isArrayLike[acf62692-3d81-11e8-b145-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isArrayLike", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the provided argument is array-like (i.e. is iterable).", 6 | "snippet": "const isArrayLike = val => {\n try {\n return [...val], true;\n } catch (e) {\n return false;\n }\n};\n", 7 | "uid": "acf62692-3d81-11e8-b145-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isBoolean[acf3c958-3d81-11e8-aa54-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isBoolean", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the given argument is a native boolean element.", 6 | "snippet": "const isBoolean = val => typeof val === 'boolean';\n", 7 | "uid": "acf3c958-3d81-11e8-aa54-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isBrowser[ad03979e-3d81-11e8-8a94-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isBrowser", 4 | "dontautoexpand" : true, 5 | "name" : "Determines if the current runtime environment is a browser so that front-end modules can run on the server (Node) without throwing errors.", 6 | "snippet": "const isBrowser = () => ![typeof window, typeof document].includes('undefined');\n", 7 | "uid": "ad03979e-3d81-11e8-8a94-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isDivisible[acf8fc78-3d81-11e8-808b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isDivisible", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the first numeric argument is divisible by the second one.", 6 | "snippet": "const isDivisible = (dividend, divisor) => dividend % divisor === 0;\n", 7 | "uid": "acf8fc78-3d81-11e8-808b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isEmpty[acfd6358-3d81-11e8-9db5-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isEmpty", 4 | "dontautoexpand" : true, 5 | "name" : "Returns true if the a value is an empty object, collection, map or set, has no enumerable properties or is any type that is not considered a collection.", 6 | "snippet": "const isEmpty = val => val == null || !(Object.keys(val) || val).length;\n", 7 | "uid": "acfd6358-3d81-11e8-9db5-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isEven[ad010bde-3d81-11e8-b790-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isEven", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the given number is even, `false` otherwise.", 6 | "snippet": "const isEven = num => num % 2 === 0;\n", 7 | "uid": "ad010bde-3d81-11e8-b790-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isFunction[acf974b4-3d81-11e8-9d7f-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isFunction", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the given argument is a function.", 6 | "snippet": "const isFunction = val => typeof val === 'function';\n", 7 | "uid": "acf974b4-3d81-11e8-9d7f-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isLowerCase[ad008346-3d81-11e8-98bc-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isLowerCase", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if a string is lower case.", 6 | "snippet": "const isLowerCase = str => str === str.toLowerCase();\n", 7 | "uid": "ad008346-3d81-11e8-98bc-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isNil[acfb593a-3d81-11e8-b4b4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isNil", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the specified value is `null` or `undefined`, `false` otherwise.", 6 | "snippet": "const isNil = val => val === undefined || val === null;\n", 7 | "uid": "acfb593a-3d81-11e8-b4b4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isNull[acffc792-3d81-11e8-9cb8-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isNull", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the specified value is `null`, `false` otherwise.", 6 | "snippet": "const isNull = val => val === null;\n", 7 | "uid": "acffc792-3d81-11e8-9cb8-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isNumber[acf6dae2-3d81-11e8-aea4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isNumber", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the given argument is a number.", 6 | "snippet": "const isNumber = val => typeof val === 'number';\n", 7 | "uid": "acf6dae2-3d81-11e8-aea4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isObjectLike[ad03da94-3d81-11e8-8721-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isObjectLike", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if a value is object-like.", 6 | "snippet": "const isObjectLike = val => val !== null && typeof val === 'object';\n", 7 | "uid": "ad03da94-3d81-11e8-8721-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isObject[acf93f3a-3d81-11e8-80fc-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isObject", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a boolean determining if the passed value is an object or not.", 6 | "snippet": "const isObject = obj => obj === Object(obj);\n", 7 | "uid": "acf93f3a-3d81-11e8-80fc-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isPlainObject[acf469cc-3d81-11e8-8486-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isPlainObject", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the provided value is an object created by the Object constructor.", 6 | "snippet": "const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object;\n", 7 | "uid": "acf469cc-3d81-11e8-8486-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isPrime[ad027a34-3d81-11e8-8d07-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isPrime", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the provided integer is a prime number.", 6 | "snippet": "const isPrime = num => {\n const boundary = Math.floor(Math.sqrt(num));\n for (var i = 2; i <= boundary; i++) if (num % i === 0) return false;\n return num >= 2;\n};\n", 7 | "uid": "ad027a34-3d81-11e8-8d07-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isPrimitive[acfafef6-3d81-11e8-9bc8-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isPrimitive", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a boolean determining if the passed value is primitive or not.", 6 | "snippet": "const isPrimitive = val => !['object', 'function'].includes(typeof val) || val === null;\n", 7 | "uid": "acfafef6-3d81-11e8-9bc8-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isPromiseLike[acf4dcc6-3d81-11e8-8470-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isPromiseLike", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if an object looks like a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), `false` otherwise.", 6 | "snippet": "const isPromiseLike = obj =>\n obj !== null &&\n (typeof obj === 'object' || typeof obj === 'function') &&\n typeof obj.then === 'function';\n", 7 | "uid": "acf4dcc6-3d81-11e8-8470-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isSorted[acfe6318-3d81-11e8-b7df-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isSorted", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `1` if the array is sorted in ascending order, `-1` if it is sorted in descending order or `0` if it is not sorted.", 6 | "snippet": "const isSorted = arr => {\n let direction = -(arr[0] - arr[1]);\n for (let [i, val] of arr.entries()) {\n direction = !direction ? -(arr[i - 1] - arr[i]) : direction;\n if (i === arr.length - 1) return !direction ? 0 : direction;\n else if ((val - arr[i + 1]) * direction > 0) return 0;\n }\n};\n", 7 | "uid": "acfe6318-3d81-11e8-b7df-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isString[acfe1b22-3d81-11e8-8b67-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isString", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the given argument is a string.", 6 | "snippet": "const isString = val => typeof val === 'string';\n", 7 | "uid": "acfe1b22-3d81-11e8-8b67-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isSymbol[acf40966-3d81-11e8-a735-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isSymbol", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the given argument is a symbol.", 6 | "snippet": "const isSymbol = val => typeof val === 'symbol';\n", 7 | "uid": "acf40966-3d81-11e8-a735-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isTravisCI[acfb3a42-3d81-11e8-86b6-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isTravisCI", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the current environment is [Travis CI](https://travis-ci.org/).", 6 | "snippet": "const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env;\n", 7 | "uid": "acfb3a42-3d81-11e8-86b6-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isUndefined[acfe7f5e-3d81-11e8-8528-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isUndefined", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the specified value is `undefined`, `false` otherwise.", 6 | "snippet": "const isUndefined = val => val === undefined;\n", 7 | "uid": "acfe7f5e-3d81-11e8-8528-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isUpperCase[acfd3fa4-3d81-11e8-abcf-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isUpperCase", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if a string is upper case.", 6 | "snippet": "const isUpperCase = str => str === str.toUpperCase();\n", 7 | "uid": "acfd3fa4-3d81-11e8-abcf-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/isValidJSON[ad023cde-3d81-11e8-b862-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "isValidJSON", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the provided argument is a valid JSON.", 6 | "snippet": "const isValidJSON = obj => {\n try {\n JSON.parse(obj);\n return true;\n } catch (e) {\n return false;\n }\n};\n", 7 | "uid": "ad023cde-3d81-11e8-b862-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/is[ad02a412-3d81-11e8-9f61-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "is", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the provided value is of the specified type (doesn't work with literals).", 6 | "snippet": "const is = (type, val) => val instanceof type;\n", 7 | "uid": "ad02a412-3d81-11e8-9f61-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/join[ad015dc8-3d81-11e8-9efb-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "join", 4 | "dontautoexpand" : true, 5 | "name" : "Joins all elements of an array into a string and returns this string. Uses a separator and an end separator.", 6 | "snippet": "const join = (arr, separator = ',', end = separator) =>\n arr.reduce(\n (acc, val, i) =>\n i === arr.length - 2\n ? acc + val + end\n : i === arr.length - 1 ? acc + val : acc + val + separator,\n ''\n );\n", 7 | "uid": "ad015dc8-3d81-11e8-9efb-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/last[acf3ffb6-3d81-11e8-8941-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "last", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the last element in an array.", 6 | "snippet": "const last = arr => arr[arr.length - 1];\n", 7 | "uid": "acf3ffb6-3d81-11e8-8941-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/lcm[acf5e45c-3d81-11e8-a7ae-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "lcm", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the least common multiple of two or more numbers.", 6 | "snippet": "const lcm = (...arr) => {\n const gcd = (x, y) => (!y ? x : gcd(y, x % y));\n const _lcm = (x, y) => x * y / gcd(x, y);\n return [...arr].reduce((a, b) => _lcm(a, b));\n};\n", 7 | "uid": "acf5e45c-3d81-11e8-a7ae-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/longestItem[ad01d942-3d81-11e8-829f-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "longestItem", 4 | "dontautoexpand" : true, 5 | "name" : "Takes any number of iterable objects or objects with a `length` property and returns the longest one.", 6 | "snippet": "const longestItem = (...vals) => [...vals].sort((a, b) => b.length - a.length)[0];\n", 7 | "uid": "ad01d942-3d81-11e8-829f-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/lowercaseKeys[acf50fb4-3d81-11e8-9406-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "lowercaseKeys", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a new object from the specified object, where all the keys are in lowercase.", 6 | "snippet": "const lowercaseKeys = obj =>\n Object.keys(obj).reduce((acc, key) => {\n acc[key.toLowerCase()] = obj[key];\n return acc;\n }, {});\n", 7 | "uid": "acf50fb4-3d81-11e8-9406-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/luhnCheck[acf71b62-3d81-11e8-920c-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "luhnCheck", 4 | "dontautoexpand" : true, 5 | "name" : "Implementation of the [Luhn Algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm) used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers etc.", 6 | "snippet": "const luhnCheck = num => {\n let arr = (num + '')\n .split('')\n .reverse()\n .map(x => parseInt(x));\n let lastDigit = arr.splice(0, 1)[0];\n let sum = arr.reduce((acc, val, i) => (i % 2 !== 0 ? acc + val : acc + (val * 2) % 9 || 9), 0);\n sum += lastDigit;\n return sum % 10 === 0;\n};\n", 7 | "uid": "acf71b62-3d81-11e8-920c-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/mapKeys[ad0284f0-3d81-11e8-9e30-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "mapKeys", 4 | "dontautoexpand" : true, 5 | "name" : "Creates an object with keys generated by running the provided function for each key and the same values as the provided object.", 6 | "snippet": "const mapKeys = (obj, fn) =>\n Object.keys(obj).reduce((acc, k) => {\n acc[fn(obj[k], k, obj)] = obj[k];\n return acc;\n }, {});\n", 7 | "uid": "ad0284f0-3d81-11e8-9e30-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/mapObject[ad006a8a-3d81-11e8-ac1b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "mapObject", 4 | "dontautoexpand" : true, 5 | "name" : "Maps the values of an array to an object using a function, where the key-value pairs consist of the original value as the key and the mapped value.", 6 | "snippet": "const mapObject = (arr, fn) =>\n (a => (\n (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {})\n ))();\n", 7 | "uid": "ad006a8a-3d81-11e8-ac1b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/mapValues[ad01b46c-3d81-11e8-b0cc-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "mapValues", 4 | "dontautoexpand" : true, 5 | "name" : "Creates an object with the same keys as the provided object and values generated by running the provided function for each value.", 6 | "snippet": "const mapValues = (obj, fn) =>\n Object.keys(obj).reduce((acc, k) => {\n acc[k] = fn(obj[k], k, obj);\n return acc;\n }, {});\n", 7 | "uid": "ad01b46c-3d81-11e8-b0cc-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/mask[acfdc028-3d81-11e8-8973-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "mask", 4 | "dontautoexpand" : true, 5 | "name" : "Replaces all but the last `num` of characters with the specified mask character.", 6 | "snippet": "const mask = (cc, num = 4, mask = '*') =>\n ('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num);\n", 7 | "uid": "acfdc028-3d81-11e8-8973-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/matchesWith[acf5258a-3d81-11e8-908d-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "matchesWith", 4 | "dontautoexpand" : true, 5 | "name" : "Compares two objects to determine if the first one contains equivalent property values to the second one, based on a provided function.", 6 | "snippet": "const matchesWith = (obj, source, fn) =>\n Object.keys(source).every(\n key =>\n obj.hasOwnProperty(key) && fn\n ? fn(obj[key], source[key], key, obj, source)\n : obj[key] == source[key]\n );\n", 7 | "uid": "acf5258a-3d81-11e8-908d-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/matches[acfe9ec6-3d81-11e8-bbda-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "matches", 4 | "dontautoexpand" : true, 5 | "name" : "Compares two objects to determine if the first one contains equivalent property values to the second one.", 6 | "snippet": "const matches = (obj, source) =>\n Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]);\n", 7 | "uid": "acfe9ec6-3d81-11e8-bbda-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/maxBy[ad025a0c-3d81-11e8-9e40-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "maxBy", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the maximum value of an array, after mapping each element to a value using the provided function.", 6 | "snippet": "const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));\n", 7 | "uid": "ad025a0c-3d81-11e8-9e40-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/maxN[acf8863a-3d81-11e8-a199-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "maxN", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the `n` maximum elements from the provided array. If `n` is greater than or equal to the provided array's length, then return the original array(sorted in descending order).", 6 | "snippet": "const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);\n", 7 | "uid": "acf8863a-3d81-11e8-a199-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/median[acf38ee6-3d81-11e8-9a06-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "median", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the median of an array of numbers.", 6 | "snippet": "const median = arr => {\n const mid = Math.floor(arr.length / 2),\n nums = [...arr].sort((a, b) => a - b);\n return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;\n};\n", 7 | "uid": "acf38ee6-3d81-11e8-9a06-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/memoize[acff9740-3d81-11e8-bd7b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "memoize", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the memoized (cached) function.", 6 | "snippet": "const memoize = fn => {\n const cache = new Map();\n const cached = function(val) {\n return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val);\n };\n cached.cache = cache;\n return cached;\n};\n", 7 | "uid": "acff9740-3d81-11e8-bd7b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/merge[acfe8f80-3d81-11e8-a528-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "merge", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a new object from the combination of two or more objects.", 6 | "snippet": "const merge = (...objs) =>\n [...objs].reduce(\n (acc, obj) =>\n Object.keys(obj).reduce((a, k) => {\n acc[k] = acc.hasOwnProperty(k) ? [].concat(acc[k]).concat(obj[k]) : obj[k];\n return acc;\n }, {}),\n {}\n );\n", 7 | "uid": "acfe8f80-3d81-11e8-a528-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/minBy[ad01c2c2-3d81-11e8-b216-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "minBy", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the minimum value of an array, after mapping each element to a value using the provided function.", 6 | "snippet": "const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));\n", 7 | "uid": "ad01c2c2-3d81-11e8-b216-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/minN[ad018622-3d81-11e8-8d76-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "minN", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the `n` minimum elements from the provided array. If `n` is greater than or equal to the provided array's length, then return the original array(sorted in ascending order).", 6 | "snippet": "const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);\n", 7 | "uid": "ad018622-3d81-11e8-8d76-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/mostPerformant[acfd823e-3d81-11e8-aad4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "mostPerformant", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the index of the function in an array of functions which executed the fastest.", 6 | "snippet": "const mostPerformant = (fns, iterations = 10000) => {\n const times = fns.map(fn => {\n const before = performance.now();\n for (let i = 0; i < iterations; i++) fn();\n return performance.now() - before;\n });\n return times.indexOf(Math.min(...times));\n};\n", 7 | "uid": "acfd823e-3d81-11e8-aad4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/negate[ad038be8-3d81-11e8-86bf-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "negate", 4 | "dontautoexpand" : true, 5 | "name" : "Negates a predicate function.", 6 | "snippet": "const negate = func => (...args) => !func(...args);\n", 7 | "uid": "ad038be8-3d81-11e8-86bf-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/nest[acfc37e4-3d81-11e8-9e05-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "nest", 4 | "dontautoexpand" : true, 5 | "name" : "Given a flat array of objects linked to one another, it will nest them recursively.", 6 | "snippet": "const nest = (items, id = null, link = 'parent_id') =>\n items\n .filter(item => item[link] === id)\n .map(item => ({ ...item, children: nest(items, item.id) }));\n", 7 | "uid": "acfc37e4-3d81-11e8-9e05-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/none[acfee6a6-3d81-11e8-b488-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "none", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the provided predicate function returns `false` for all elements in a collection, `false` otherwise.", 6 | "snippet": "const none = (arr, fn = Boolean) => !arr.some(fn);\n", 7 | "uid": "acfee6a6-3d81-11e8-b488-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/nthArg[acf748a6-3d81-11e8-859a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "nthArg", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a function that gets the argument at index `n`. If `n` is negative, the nth argument from the end is returned.", 6 | "snippet": "const nthArg = n => (...args) => args.slice(n)[0];\n", 7 | "uid": "acf748a6-3d81-11e8-859a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/nthElement[acf650d8-3d81-11e8-83d3-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "nthElement", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the nth element of an array.", 6 | "snippet": "const nthElement = (arr, n = 0) => (n > 0 ? arr.slice(n, n + 1) : arr.slice(n))[0];\n", 7 | "uid": "acf650d8-3d81-11e8-83d3-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/objectFromPairs[acf9e19c-3d81-11e8-b764-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "objectFromPairs", 4 | "dontautoexpand" : true, 5 | "name" : "Creates an object from the given key-value pairs.", 6 | "snippet": "const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {});\n", 7 | "uid": "acf9e19c-3d81-11e8-b764-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/objectToPairs[acfbcc9e-3d81-11e8-a488-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "objectToPairs", 4 | "dontautoexpand" : true, 5 | "name" : "Creates an array of key-value pair arrays from an object.", 6 | "snippet": "const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);\n", 7 | "uid": "acfbcc9e-3d81-11e8-a488-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/observeMutations[ad00ee68-3d81-11e8-8aaa-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "observeMutations", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a new MutationObserver and runs the provided callback for each mutation on the specified element.", 6 | "snippet": "const observeMutations = (element, callback, options) => {\n const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m)));\n observer.observe(\n element,\n Object.assign(\n {\n childList: true,\n attributes: true,\n attributeOldValue: true,\n characterData: true,\n characterDataOldValue: true,\n subtree: true\n },\n options\n )\n );\n return observer;\n};\n", 7 | "uid": "ad00ee68-3d81-11e8-8aaa-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/off[acfc6e76-3d81-11e8-819d-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "off", 4 | "dontautoexpand" : true, 5 | "name" : "Removes an event listener from an element.", 6 | "snippet": "const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts);\n", 7 | "uid": "acfc6e76-3d81-11e8-819d-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/offset[ad016908-3d81-11e8-baab-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "offset", 4 | "dontautoexpand" : true, 5 | "name" : "Moves the specified amount of elements to the end of the array.", 6 | "snippet": "const offset = (arr, offset) => [...arr.slice(offset), ...arr.slice(0, offset)];\n", 7 | "uid": "ad016908-3d81-11e8-baab-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/omitBy[acf906b4-3d81-11e8-96f5-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "omitBy", 4 | "dontautoexpand" : true, 5 | "name" : "Creates an object composed of the properties the given function returns falsey for. The function is invoked with two arguments: (value, key).", 6 | "snippet": "const omitBy = (obj, fn) =>\n Object.keys(obj)\n .filter(k => !fn(obj[k], k))\n .reduce((acc, key) => ((acc[key] = obj[key]), acc), {});\n", 7 | "uid": "acf906b4-3d81-11e8-96f5-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/omit[acfdf2d2-3d81-11e8-9abd-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "omit", 4 | "dontautoexpand" : true, 5 | "name" : "Omits the key-value pairs corresponding to the given keys from an object.", 6 | "snippet": "const omit = (obj, arr) =>\n Object.keys(obj)\n .filter(k => !arr.includes(k))\n .reduce((acc, key) => ((acc[key] = obj[key]), acc), {});\n", 7 | "uid": "acfdf2d2-3d81-11e8-9abd-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/onUserInputChange[acf63fec-3d81-11e8-ada4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "onUserInputChange", 4 | "dontautoexpand" : true, 5 | "name" : "Run the callback whenever the user input type changes (`mouse` or `touch`). Useful for enabling/disabling code depending on the input device. This process is dynamic and works with hybrid devices (e.g. touchscreen laptops).", 6 | "snippet": "const onUserInputChange = callback => {\n let type = 'mouse',\n lastTime = 0;\n const mousemoveHandler = () => {\n const now = performance.now();\n if (now - lastTime < 20)\n (type = 'mouse'), callback(type), document.removeEventListener('mousemove', mousemoveHandler);\n lastTime = now;\n };\n document.addEventListener('touchstart', () => {\n if (type === 'touch') return;\n (type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler);\n });\n};\n", 7 | "uid": "acf63fec-3d81-11e8-ada4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/on[ad024c92-3d81-11e8-beb5-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "on", 4 | "dontautoexpand" : true, 5 | "name" : "Adds an event listener to an element with the ability to use event delegation.", 6 | "snippet": "const on = (el, evt, fn, opts = {}) => {\n const delegatorFn = e => e.target.matches(opts.target) && fn.call(e.target, e);\n el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false);\n if (opts.target) return delegatorFn;\n};\n", 7 | "uid": "ad024c92-3d81-11e8-beb5-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/once[acf579fe-3d81-11e8-bc51-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "once", 4 | "dontautoexpand" : true, 5 | "name" : "Ensures a function is called only once.", 6 | "snippet": "const once = fn => {\n let called = false;\n return function(...args) {\n if (called) return;\n called = true;\n return fn.apply(this, args);\n };\n};\n", 7 | "uid": "acf579fe-3d81-11e8-bc51-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/orderBy[acf9b5c8-3d81-11e8-8eac-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "orderBy", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a sorted array of objects ordered by properties and orders.", 6 | "snippet": "const orderBy = (arr, props, orders) =>\n [...arr].sort((a, b) =>\n props.reduce((acc, prop, i) => {\n if (acc === 0) {\n const [p1, p2] = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]];\n acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0;\n }\n return acc;\n }, 0)\n );\n", 7 | "uid": "acf9b5c8-3d81-11e8-8eac-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/overArgs[acf17822-3d81-11e8-b4d0-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "overArgs", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a function that invokes the provided function with its arguments transformed.", 6 | "snippet": "const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val)));\n", 7 | "uid": "acf17822-3d81-11e8-b4d0-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/over[acf7d726-3d81-11e8-bd7a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "over", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a function that invokes each provided function with the arguments it receives and returns the results.", 6 | "snippet": "const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args));\n", 7 | "uid": "acf7d726-3d81-11e8-bd7a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/pad[acf5b3d8-3d81-11e8-bcaf-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "pad", 4 | "dontautoexpand" : true, 5 | "name" : "Pads a string on both sides with the specified character, if it's shorter than the specified length.", 6 | "snippet": "const pad = (str, length, char = ' ') =>\n str.padStart((str.length + length) / 2, char).padEnd(length, char);\n", 7 | "uid": "acf5b3d8-3d81-11e8-bcaf-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/palindrome[acfeba34-3d81-11e8-a971-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "palindrome", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the given string is a palindrome, `false` otherwise.", 6 | "snippet": "const palindrome = str => {\n const s = str.toLowerCase().replace(/[\W_]/g, '');\n return (\n s ===\n s\n .split('')\n .reverse()\n .join('')\n );\n};\n", 7 | "uid": "acfeba34-3d81-11e8-a971-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/parseCookie[acfb0ec8-3d81-11e8-b9c6-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "parseCookie", 4 | "dontautoexpand" : true, 5 | "name" : "Parse an HTTP Cookie header string and return an object of all cookie name-value pairs.", 6 | "snippet": "const parseCookie = str =>\n str\n .split(';')\n .map(v => v.split('='))\n .reduce((acc, v) => {\n acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim());\n return acc;\n }, {});\n", 7 | "uid": "acfb0ec8-3d81-11e8-b9c6-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/partialRight[acf6a998-3d81-11e8-9f6d-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "partialRight", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a function that invokes `fn` with `partials` appended to the arguments it receives.", 6 | "snippet": "const partialRight = (fn, ...partials) => (...args) => fn(...args, ...partials);\n", 7 | "uid": "acf6a998-3d81-11e8-9f6d-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/partial[acf94fe8-3d81-11e8-83ea-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "partial", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a function that invokes `fn` with `partials` prepended to the arguments it receives.", 6 | "snippet": "const partial = (fn, ...partials) => (...args) => fn(...partials, ...args);\n", 7 | "uid": "acf94fe8-3d81-11e8-83ea-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/partition[acfc2de4-3d81-11e8-82d5-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "partition", 4 | "dontautoexpand" : true, 5 | "name" : "Groups the elements into two arrays, depending on the provided function's truthiness for each element.", 6 | "snippet": "const partition = (arr, fn) =>\n arr.reduce(\n (acc, val, i, arr) => {\n acc[fn(val, i, arr) ? 0 : 1].push(val);\n return acc;\n },\n [[], []]\n );\n", 7 | "uid": "acfc2de4-3d81-11e8-82d5-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/percentile[acf84e9a-3d81-11e8-baa6-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "percentile", 4 | "dontautoexpand" : true, 5 | "name" : "Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value.", 6 | "snippet": "const percentile = (arr, val) =>\n 100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0) / arr.length;\n", 7 | "uid": "acf84e9a-3d81-11e8-baa6-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/permutations[acfff000-3d81-11e8-9d7a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "permutations", 4 | "dontautoexpand" : true, 5 | "name" : "⚠️ **WARNING**: This function's execution time increases exponentially with each array element. Anything more than 8 to 10 entries will cause your browser to hang as it tries to solve all the different combinations.", 6 | "snippet": "const permutations = arr => {\n if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr;\n return arr.reduce(\n (acc, item, i) =>\n acc.concat(\n permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [item, ...val])\n ),\n []\n );\n};\n", 7 | "uid": "acfff000-3d81-11e8-9d7a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/pickBy[ad020d22-3d81-11e8-b613-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "pickBy", 4 | "dontautoexpand" : true, 5 | "name" : "Creates an object composed of the properties the given function returns truthy for. The function is invoked with two arguments: (value, key).", 6 | "snippet": "const pickBy = (obj, fn) =>\n Object.keys(obj)\n .filter(k => fn(obj[k], k))\n .reduce((acc, key) => ((acc[key] = obj[key]), acc), {});\n", 7 | "uid": "ad020d22-3d81-11e8-b613-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/pick[acf59d80-3d81-11e8-91a6-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "pick", 4 | "dontautoexpand" : true, 5 | "name" : "Picks the key-value pairs corresponding to the given keys from an object.", 6 | "snippet": "const pick = (obj, arr) =>\n arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {});\n", 7 | "uid": "acf59d80-3d81-11e8-91a6-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/pipeAsyncFunctions[ad02ce06-3d81-11e8-b61b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "pipeAsyncFunctions", 4 | "dontautoexpand" : true, 5 | "name" : "Performs left-to-right function composition for asynchronous functions.", 6 | "snippet": "const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg));\n", 7 | "uid": "ad02ce06-3d81-11e8-b61b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/pipeFunctions[acf41d02-3d81-11e8-848c-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "pipeFunctions", 4 | "dontautoexpand" : true, 5 | "name" : "Performs left-to-right function composition.", 6 | "snippet": "const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));\n", 7 | "uid": "acf41d02-3d81-11e8-848c-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/pluralize[acf4b28a-3d81-11e8-97c3-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "pluralize", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the singular or plural form of the word based on the input number. If the first argument is an `object`, it will use a closure by returning a function that can auto-pluralize words that don't simply end in `s` if the supplied dictionary contains the word.", 6 | "snippet": "const pluralize = (val, word, plural = word + 's') => {\n const _pluralize = (num, word, plural = word + 's') =>\n [1, -1].includes(Number(num)) ? word : plural;\n if (typeof val === 'object') return (num, word) => _pluralize(num, word, val[word]);\n return _pluralize(val, word, plural);\n};\n", 7 | "uid": "acf4b28a-3d81-11e8-97c3-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/powerset[acf3b452-3d81-11e8-8f36-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "powerset", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the powerset of a given array of numbers.", 6 | "snippet": "const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]);\n", 7 | "uid": "acf3b452-3d81-11e8-8f36-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/prefix[acfdcb18-3d81-11e8-ac83-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "prefix", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the prefixed version (if necessary) of a CSS property that the browser supports.", 6 | "snippet": "const prefix = prop => {\n const capitalizedProp = prop.charAt(0).toUpperCase() + prop.slice(1);\n const prefixes = ['', 'webkit', 'moz', 'ms', 'o'];\n const i = prefixes.findIndex(\n prefix => typeof document.body.style[prefix ? prefix + capitalizedProp : prop] !== 'undefined'\n );\n return i !== -1 ? (i === 0 ? prop : prefixes[i] + capitalizedProp) : null;\n};\n", 7 | "uid": "acfdcb18-3d81-11e8-ac83-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/prettyBytes[ad017628-3d81-11e8-b7d7-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "prettyBytes", 4 | "dontautoexpand" : true, 5 | "name" : "Converts a number in bytes to a human-readable string.", 6 | "snippet": "const prettyBytes = (num, precision = 3, addSpace = true) => {\n const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n if (Math.abs(num) < 1) return num + (addSpace ? ' ' : '') + UNITS[0];\n const exponent = Math.min(Math.floor(Math.log10(num < 0 ? -num : num) / 3), UNITS.length - 1);\n const n = Number(((num < 0 ? -num : num) / 1000 ** exponent).toPrecision(precision));\n return (num < 0 ? '-' : '') + n + (addSpace ? ' ' : '') + UNITS[exponent];\n};\n", 7 | "uid": "ad017628-3d81-11e8-b7d7-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/primes[acfd4ee8-3d81-11e8-9129-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "primes", 4 | "dontautoexpand" : true, 5 | "name" : "Generates primes up to a given number, using the Sieve of Eratosthenes.", 6 | "snippet": "const primes = num => {\n let arr = Array.from({ length: num - 1 }).map((x, i) => i + 2),\n sqroot = Math.floor(Math.sqrt(num)),\n numsTillSqroot = Array.from({ length: sqroot - 1 }).map((x, i) => i + 2);\n numsTillSqroot.forEach(x => (arr = arr.filter(y => y % x !== 0 || y === x)));\n return arr;\n};\n", 7 | "uid": "acfd4ee8-3d81-11e8-9129-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/promisify[acf4806c-3d81-11e8-81f4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "promisify", 4 | "dontautoexpand" : true, 5 | "name" : "Converts an asynchronous function to return a promise.", 6 | "snippet": "const promisify = func => (...args) =>\n new Promise((resolve, reject) =>\n func(...args, (err, result) => (err ? reject(err) : resolve(result)))\n );\n", 7 | "uid": "acf4806c-3d81-11e8-81f4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/pullAtIndex[acfdb4ca-3d81-11e8-88fb-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "pullAtIndex", 4 | "dontautoexpand" : true, 5 | "name" : "Mutates the original array to filter out the values at the specified indexes.", 6 | "snippet": "const pullAtIndex = (arr, pullArr) => {\n let removed = [];\n let pulled = arr\n .map((v, i) => (pullArr.includes(i) ? removed.push(v) : v))\n .filter((v, i) => !pullArr.includes(i));\n arr.length = 0;\n pulled.forEach(v => arr.push(v));\n return removed;\n};\n", 7 | "uid": "acfdb4ca-3d81-11e8-88fb-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/pullAtValue[acf8238c-3d81-11e8-a897-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "pullAtValue", 4 | "dontautoexpand" : true, 5 | "name" : "Mutates the original array to filter out the values specified. Returns the removed elements.", 6 | "snippet": "const pullAtValue = (arr, pullArr) => {\n let removed = [],\n pushToRemove = arr.forEach((v, i) => (pullArr.includes(v) ? removed.push(v) : v)),\n mutateTo = arr.filter((v, i) => !pullArr.includes(v));\n arr.length = 0;\n mutateTo.forEach(v => arr.push(v));\n return removed;\n};\n", 7 | "uid": "acf8238c-3d81-11e8-a897-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/pullBy[acf8f086-3d81-11e8-ae41-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "pullBy", 4 | "dontautoexpand" : true, 5 | "name" : "Mutates the original array to filter out the values specified, based on a given iterator function.", 6 | "snippet": "const pullBy = (arr, ...args) => {\n const length = args.length;\n let fn = length > 1 ? args[length - 1] : undefined;\n fn = typeof fn == 'function' ? (args.pop(), fn) : undefined;\n let argState = (Array.isArray(args[0]) ? args[0] : args).map(val => fn(val));\n let pulled = arr.filter((v, i) => !argState.includes(fn(v)));\n arr.length = 0;\n pulled.forEach(v => arr.push(v));\n};\n", 7 | "uid": "acf8f086-3d81-11e8-ae41-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/pull[acfc50c6-3d81-11e8-8082-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "pull", 4 | "dontautoexpand" : true, 5 | "name" : "Mutates the original array to filter out the values specified.", 6 | "snippet": "const pull = (arr, ...args) => {\n let argState = Array.isArray(args[0]) ? args[0] : args;\n let pulled = arr.filter((v, i) => !argState.includes(v));\n arr.length = 0;\n pulled.forEach(v => arr.push(v));\n};\n", 7 | "uid": "acfc50c6-3d81-11e8-8082-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/radsToDegrees[acf75936-3d81-11e8-8e18-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "radsToDegrees", 4 | "dontautoexpand" : true, 5 | "name" : "Converts an angle from radians to degrees.", 6 | "snippet": "const radsToDegrees = rad => rad * 180.0 / Math.PI;\n", 7 | "uid": "acf75936-3d81-11e8-8e18-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/randomHexColorCode[acf6c412-3d81-11e8-bbd9-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "randomHexColorCode", 4 | "dontautoexpand" : true, 5 | "name" : "Generates a random hexadecimal color code.", 6 | "snippet": "const randomHexColorCode = () => {\n let n = (Math.random() * 0xfffff * 1000000).toString(16);\n return '#' + n.slice(0, 6);\n};\n", 7 | "uid": "acf6c412-3d81-11e8-bbd9-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/randomIntArrayInRange[acf7a5ba-3d81-11e8-821e-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "randomIntArrayInRange", 4 | "dontautoexpand" : true, 5 | "name" : "Returns an array of n random integers in the specified range.", 6 | "snippet": "const randomIntArrayInRange = (min, max, n = 1) =>\n Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min);\n", 7 | "uid": "acf7a5ba-3d81-11e8-821e-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/randomIntegerInRange[ad007822-3d81-11e8-ac75-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "randomIntegerInRange", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a random integer in the specified range.", 6 | "snippet": "const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;\n", 7 | "uid": "ad007822-3d81-11e8-ac75-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/randomNumberInRange[acfdfeba-3d81-11e8-9926-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "randomNumberInRange", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a random number in the specified range.", 6 | "snippet": "const randomNumberInRange = (min, max) => Math.random() * (max - min) + min;\n", 7 | "uid": "acfdfeba-3d81-11e8-9926-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/readFileLines[acfb7354-3d81-11e8-ad1d-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "readFileLines", 4 | "dontautoexpand" : true, 5 | "name" : "Returns an array of lines from the specified file.", 6 | "snippet": "const fs = require('fs');\nconst readFileLines = filename =>\n fs\n .readFileSync(filename)\n .toString('UTF8')\n .split('\n');\n", 7 | "uid": "acfb7354-3d81-11e8-ad1d-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/rearg[ad02fc9e-3d81-11e8-8163-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "rearg", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a function that invokes the provided function with its arguments arranged according to the specified indexes.", 6 | "snippet": "const rearg = (fn, indexes) => (...args) =>\n fn(\n ...args.reduce(\n (acc, val, i) => ((acc[indexes.indexOf(i)] = val), acc),\n Array.from({ length: indexes.length })\n )\n );\n", 7 | "uid": "ad02fc9e-3d81-11e8-8163-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/recordAnimationFrames[acf6fb8a-3d81-11e8-8505-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "recordAnimationFrames", 4 | "dontautoexpand" : true, 5 | "name" : "Invokes the provided callback on each animation frame.", 6 | "snippet": "const recordAnimationFrames = (callback, autoStart = true) => {\n let running = true,\n raf;\n const stop = () => {\n running = false;\n cancelAnimationFrame(raf);\n };\n const start = () => {\n running = true;\n run();\n };\n const run = () => {\n raf = requestAnimationFrame(() => {\n callback();\n if (running) run();\n });\n };\n if (autoStart) start();\n return { start, stop };\n};\n", 7 | "uid": "acf6fb8a-3d81-11e8-8505-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/redirect[ad029a08-3d81-11e8-9034-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "redirect", 4 | "dontautoexpand" : true, 5 | "name" : "Redirects to a specified URL.", 6 | "snippet": "const redirect = (url, asLink = true) =>\n asLink ? (window.location.href = url) : window.location.replace(url);\n", 7 | "uid": "ad029a08-3d81-11e8-9034-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/reduceSuccessive[acf87a50-3d81-11e8-b86b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "reduceSuccessive", 4 | "dontautoexpand" : true, 5 | "name" : "Applies a function against an accumulator and each element in the array (from left to right), returning an array of successively reduced values.", 6 | "snippet": "const reduceSuccessive = (arr, fn, acc) =>\n arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]);\n", 7 | "uid": "acf87a50-3d81-11e8-b86b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/reduceWhich[ad033e40-3d81-11e8-8051-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "reduceWhich", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the minimum/maximum value of an array, after applying the provided function to set comparing rule.", 6 | "snippet": "const reduceWhich = (arr, comparator = (a, b) => a - b) =>\n arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a));\n", 7 | "uid": "ad033e40-3d81-11e8-8051-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/reducedFilter[acf923a6-3d81-11e8-8f17-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "reducedFilter", 4 | "dontautoexpand" : true, 5 | "name" : "Filter an array of objects based on a condition while also filtering out unspecified keys.", 6 | "snippet": "const reducedFilter = (data, keys, fn) =>\n data.filter(fn).map(el =>\n keys.reduce((acc, key) => {\n acc[key] = el[key];\n return acc;\n }, {})\n );\n", 7 | "uid": "acf923a6-3d81-11e8-8f17-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/removeNonASCII[acf95d80-3d81-11e8-b845-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "removeNonASCII", 4 | "dontautoexpand" : true, 5 | "name" : "Removes non-printable ASCII characters.", 6 | "snippet": "const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, '');\n", 7 | "uid": "acf95d80-3d81-11e8-b845-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/remove[ad031514-3d81-11e8-868a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "remove", 4 | "dontautoexpand" : true, 5 | "name" : "Removes elements from an array for which the given function returns `false`.", 6 | "snippet": "const remove = (arr, func) =>\n Array.isArray(arr)\n ? arr.filter(func).reduce((acc, val) => {\n arr.splice(arr.indexOf(val), 1);\n return acc.concat(val);\n }, [])\n : [];\n", 7 | "uid": "ad031514-3d81-11e8-868a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/reverseString[acfb2d18-3d81-11e8-9f78-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "reverseString", 4 | "dontautoexpand" : true, 5 | "name" : "Reverses a string.", 6 | "snippet": "const reverseString = str => [...str].reverse().join('');\n", 7 | "uid": "acfb2d18-3d81-11e8-9f78-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/round[acf6ebc2-3d81-11e8-a025-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "round", 4 | "dontautoexpand" : true, 5 | "name" : "Rounds a number to a specified amount of digits.", 6 | "snippet": "const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);\n", 7 | "uid": "acf6ebc2-3d81-11e8-a025-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/runAsync[acf7751a-3d81-11e8-8204-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "runAsync", 4 | "dontautoexpand" : true, 5 | "name" : "Runs a function in a separate thread by using a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers), allowing long running functions to not block the UI.", 6 | "snippet": "const runAsync = fn => {\n const worker = new Worker(\n URL.createObjectURL(new Blob([`postMessage((${fn})());`]), {\n type: 'application/javascript; charset=utf-8'\n })\n );\n return new Promise((res, rej) => {\n worker.onmessage = ({ data }) => {\n res(data), worker.terminate();\n };\n worker.onerror = err => {\n rej(err), worker.terminate();\n };\n });\n};\n", 7 | "uid": "acf7751a-3d81-11e8-8204-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/runPromisesInSeries[acfadf66-3d81-11e8-9a3a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "runPromisesInSeries", 4 | "dontautoexpand" : true, 5 | "name" : "Runs an array of promises in series.", 6 | "snippet": "const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve());\n", 7 | "uid": "acfadf66-3d81-11e8-9a3a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/sampleSize[acf617c6-3d81-11e8-afd3-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "sampleSize", 4 | "dontautoexpand" : true, 5 | "name" : "Gets `n` random elements at unique keys from `array` up to the size of `array`.", 6 | "snippet": "const sampleSize = ([...arr], n = 1) => {\n let m = arr.length;\n while (m) {\n const i = Math.floor(Math.random() * m--);\n [arr[m], arr[i]] = [arr[i], arr[m]];\n }\n return arr.slice(0, n);\n};\n", 7 | "uid": "acf617c6-3d81-11e8-afd3-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/sample[acf4fe66-3d81-11e8-bba3-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "sample", 4 | "dontautoexpand" : true, 5 | "name" : "Returns a random element from an array.", 6 | "snippet": "const sample = arr => arr[Math.floor(Math.random() * arr.length)];\n", 7 | "uid": "acf4fe66-3d81-11e8-bba3-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/scrollToTop[acf898dc-3d81-11e8-9483-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "scrollToTop", 4 | "dontautoexpand" : true, 5 | "name" : "Smooth-scrolls to the top of the page.", 6 | "snippet": "const scrollToTop = () => {\n const c = document.documentElement.scrollTop || document.body.scrollTop;\n if (c > 0) {\n window.requestAnimationFrame(scrollToTop);\n window.scrollTo(0, c - c / 8);\n }\n};\n", 7 | "uid": "acf898dc-3d81-11e8-9483-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/sdbm[acfbbd9e-3d81-11e8-a9fa-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "sdbm", 4 | "dontautoexpand" : true, 5 | "name" : "Hashes the input string into a whole number.", 6 | "snippet": "const sdbm = str => {\n let arr = str.split('');\n return arr.reduce(\n (hashCode, currentVal) =>\n (hashCode = currentVal.charCodeAt(0) + (hashCode << 6) + (hashCode << 16) - hashCode),\n 0\n );\n};\n", 7 | "uid": "acfbbd9e-3d81-11e8-a9fa-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/serializeCookie[ad01fcc6-3d81-11e8-83f8-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "serializeCookie", 4 | "dontautoexpand" : true, 5 | "name" : "Serialize a cookie name-value pair into a Set-Cookie header string.", 6 | "snippet": "const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`;\n", 7 | "uid": "ad01fcc6-3d81-11e8-83f8-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/setStyle[acff8c46-3d81-11e8-9c9a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "setStyle", 4 | "dontautoexpand" : true, 5 | "name" : "Sets the value of a CSS rule for the specified element.", 6 | "snippet": "const setStyle = (el, ruleName, val) => (el.style[ruleName] = val);\n", 7 | "uid": "acff8c46-3d81-11e8-9c9a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/shallowClone[acfa1434-3d81-11e8-b400-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "shallowClone", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a shallow clone of an object.", 6 | "snippet": "const shallowClone = obj => Object.assign({}, obj);\n", 7 | "uid": "acfa1434-3d81-11e8-b400-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/show[acffbc18-3d81-11e8-a802-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "show", 4 | "dontautoexpand" : true, 5 | "name" : "Shows all the elements specified.", 6 | "snippet": "const show = (...el) => [...el].forEach(e => (e.style.display = ''));\n", 7 | "uid": "acffbc18-3d81-11e8-a802-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/shuffle[acf69334-3d81-11e8-a09c-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "shuffle", 4 | "dontautoexpand" : true, 5 | "name" : "Randomizes the order of the values of an array, returning a new array.", 6 | "snippet": "const shuffle = ([...arr]) => {\n let m = arr.length;\n while (m) {\n const i = Math.floor(Math.random() * m--);\n [arr[m], arr[i]] = [arr[i], arr[m]];\n }\n return arr;\n};\n", 7 | "uid": "acf69334-3d81-11e8-a09c-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/similarity[acfcc4b6-3d81-11e8-8ce8-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "similarity", 4 | "dontautoexpand" : true, 5 | "name" : "Returns an array of elements that appear in both arrays.", 6 | "snippet": "const similarity = (arr, values) => arr.filter(v => values.includes(v));\n", 7 | "uid": "acfcc4b6-3d81-11e8-8ce8-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/size[ad013386-3d81-11e8-96f7-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "size", 4 | "dontautoexpand" : true, 5 | "name" : "Get size of arrays, objects or strings.", 6 | "snippet": "const size = val =>\n Array.isArray(val)\n ? val.length\n : val && typeof val === 'object'\n ? val.size || val.length || Object.keys(val).length\n : typeof val === 'string' ? new Blob([val]).size : 0;\n", 7 | "uid": "ad013386-3d81-11e8-96f7-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/sleep[acf43bc0-3d81-11e8-bce3-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "sleep", 4 | "dontautoexpand" : true, 5 | "name" : "Delays the execution of an asynchronous function.", 6 | "snippet": "const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));\n", 7 | "uid": "acf43bc0-3d81-11e8-bce3-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/smoothScroll[ad037090-3d81-11e8-89d9-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "smoothScroll", 4 | "dontautoexpand" : true, 5 | "name" : "Smoothly scrolls the element on which it's called into the visible area of the browser window.", 6 | "snippet": "const smoothScroll = element =>\n document.querySelector(element).scrollIntoView({\n behavior: 'smooth'\n });\n", 7 | "uid": "ad037090-3d81-11e8-89d9-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/sortCharactersInString[acf54e18-3d81-11e8-81b5-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "sortCharactersInString", 4 | "dontautoexpand" : true, 5 | "name" : "Alphabetically sorts the characters in a string.", 6 | "snippet": "const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join('');\n", 7 | "uid": "acf54e18-3d81-11e8-81b5-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/sortedIndexBy[acfc18f4-3d81-11e8-b548-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "sortedIndexBy", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the lowest index at which value should be inserted into array in order to maintain its sort order, based on a provided iterator function.", 6 | "snippet": "const sortedIndexBy = (arr, n, fn) => {\n const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]);\n const val = fn(n);\n const index = arr.findIndex(el => (isDescending ? val >= fn(el) : val <= fn(el)));\n return index === -1 ? arr.length : index;\n};\n", 7 | "uid": "acfc18f4-3d81-11e8-b548-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/sortedIndex[acf9c888-3d81-11e8-a4a1-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "sortedIndex", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the lowest index at which value should be inserted into array in order to maintain its sort order.", 6 | "snippet": "const sortedIndex = (arr, n) => {\n const isDescending = arr[0] > arr[arr.length - 1];\n const index = arr.findIndex(el => (isDescending ? n >= el : n <= el));\n return index === -1 ? arr.length : index;\n};\n", 7 | "uid": "acf9c888-3d81-11e8-a4a1-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/sortedLastIndexBy[acf66b02-3d81-11e8-9e20-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "sortedLastIndexBy", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the highest index at which value should be inserted into array in order to maintain its sort order, based on a provided iterator function.", 6 | "snippet": "const sortedLastIndexBy = (arr, n, fn) => {\n const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]);\n const val = fn(n);\n const index = arr\n .map(fn)\n .reverse()\n .findIndex(el => (isDescending ? val <= el : val >= el));\n return index === -1 ? 0 : arr.length - index;\n};\n", 7 | "uid": "acf66b02-3d81-11e8-9e20-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/sortedLastIndex[ad037fd8-3d81-11e8-9de4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "sortedLastIndex", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the highest index at which value should be inserted into array in order to maintain its sort order.", 6 | "snippet": "const sortedLastIndex = (arr, n) => {\n const isDescending = arr[0] > arr[arr.length - 1];\n const index = arr.reverse().findIndex(el => (isDescending ? n <= el : n >= el));\n return index === -1 ? 0 : arr.length - index;\n};\n", 7 | "uid": "ad037fd8-3d81-11e8-9de4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/splitLines[ad01ed4c-3d81-11e8-a3e5-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "splitLines", 4 | "dontautoexpand" : true, 5 | "name" : "Splits a multiline string into an array of lines.", 6 | "snippet": "const splitLines = str => str.split(/\r?\n/);\n", 7 | "uid": "ad01ed4c-3d81-11e8-a3e5-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/spreadOver[ad03cc52-3d81-11e8-ba1b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "spreadOver", 4 | "dontautoexpand" : true, 5 | "name" : "Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.", 6 | "snippet": "const spreadOver = fn => argsArr => fn(...argsArr);\n", 7 | "uid": "ad03cc52-3d81-11e8-ba1b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/stableSort[ad004034-3d81-11e8-aba6-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "stableSort", 4 | "dontautoexpand" : true, 5 | "name" : "Performs stable sorting of an array, preserving the initial indexes of items when their values are the same. ", 6 | "snippet": "const stableSort = (arr, compare) =>\n arr\n .map((item, index) => ({ item, index }))\n .sort((a, b) => compare(a.item, b.item) || a.index - b.index)\n .map(({ item }) => item);\n", 7 | "uid": "ad004034-3d81-11e8-aba6-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/standardDeviation[acfec68a-3d81-11e8-b321-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "standardDeviation", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the standard deviation of an array of numbers.", 6 | "snippet": "const standardDeviation = (arr, usePopulation = false) => {\n const mean = arr.reduce((acc, val) => acc + val, 0) / arr.length;\n return Math.sqrt(\n arr.reduce((acc, val) => acc.concat((val - mean) ** 2), []).reduce((acc, val) => acc + val, 0) /\n (arr.length - (usePopulation ? 0 : 1))\n );\n};\n", 7 | "uid": "acfec68a-3d81-11e8-b321-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/stringPermutations[acfbdbe6-3d81-11e8-9a4c-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "stringPermutations", 4 | "dontautoexpand" : true, 5 | "name" : "⚠️ **WARNING**: This function's execution time increases exponentially with each character. Anything more than 8 to 10 characters will cause your browser to hang as it tries to solve all the different combinations.", 6 | "snippet": "const stringPermutations = str => {\n if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];\n return str\n .split('')\n .reduce(\n (acc, letter, i) =>\n acc.concat(stringPermutations(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)),\n []\n );\n};\n", 7 | "uid": "acfbdbe6-3d81-11e8-9a4c-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/stripHTMLTags[acff7eb8-3d81-11e8-a129-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "stripHTMLTags", 4 | "dontautoexpand" : true, 5 | "name" : "Removes HTML/XML tags from string.", 6 | "snippet": "const stripHTMLTags = str => str.replace(/<[^>]*>/g, '');\n", 7 | "uid": "acff7eb8-3d81-11e8-a129-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/sumBy[acf3e77e-3d81-11e8-a34b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "sumBy", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the sum of an array, after mapping each element to a value using the provided function.", 6 | "snippet": "const sumBy = (arr, fn) =>\n arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0);\n", 7 | "uid": "acf3e77e-3d81-11e8-a34b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/sumPower[acfa4718-3d81-11e8-962e-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "sumPower", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the sum of the powers of all the numbers from `start` to `end` (both inclusive).", 6 | "snippet": "const sumPower = (end, power = 2, start = 1) =>\n Array(end + 1 - start)\n .fill(0)\n .map((x, i) => (i + start) ** power)\n .reduce((a, b) => a + b, 0);\n", 7 | "uid": "acfa4718-3d81-11e8-962e-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/sum[acf98334-3d81-11e8-b260-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "sum", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the sum of two or more numbers/arrays.", 6 | "snippet": "const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0);\n", 7 | "uid": "acf98334-3d81-11e8-b260-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/symmetricDifferenceBy[ad022cb4-3d81-11e8-b6a9-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "symmetricDifferenceBy", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the symmetric difference between two arrays, after applying the provided function to each array element of both.", 6 | "snippet": "const symmetricDifferenceBy = (a, b, fn) => {\n const sA = new Set(a.map(v => fn(v))),\n sB = new Set(b.map(v => fn(v)));\n return [...a.filter(x => !sB.has(fn(x))), ...b.filter(x => !sA.has(fn(x)))];\n};\n", 7 | "uid": "ad022cb4-3d81-11e8-b6a9-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/symmetricDifferenceWith[acfba342-3d81-11e8-9dd0-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "symmetricDifferenceWith", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the symmetric difference between two arrays, using a provided function as a comparator.", 6 | "snippet": "const symmetricDifferenceWith = (arr, val, comp) => [\n ...arr.filter(a => val.findIndex(b => comp(a, b)) === -1),\n ...val.filter(a => arr.findIndex(b => comp(a, b)) === -1)\n];\n", 7 | "uid": "acfba342-3d81-11e8-9dd0-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/symmetricDifference[acfc826c-3d81-11e8-a03a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "symmetricDifference", 4 | "dontautoexpand" : true, 5 | "name" : "Returns the symmetric difference between two arrays.", 6 | "snippet": "const symmetricDifference = (a, b) => {\n const sA = new Set(a),\n sB = new Set(b);\n return [...a.filter(x => !sB.has(x)), ...b.filter(x => !sA.has(x))];\n};\n", 7 | "uid": "acfc826c-3d81-11e8-a03a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/tail[acfeff10-3d81-11e8-b87f-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "tail", 4 | "dontautoexpand" : true, 5 | "name" : "Returns all elements in an array except for the first one.", 6 | "snippet": "const tail = arr => (arr.length > 1 ? arr.slice(1) : arr);\n", 7 | "uid": "acfeff10-3d81-11e8-b87f-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/takeRightWhile[acf81498-3d81-11e8-a92a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "takeRightWhile", 4 | "dontautoexpand" : true, 5 | "name" : "Removes elements from the end of an array until the passed function returns `true`. Returns the removed elements.", 6 | "snippet": "const takeRightWhile = (arr, func) => {\n for (let i of arr.reverse().keys())\n if (func(arr[i])) return arr.reverse().slice(arr.length - i, arr.length);\n return arr;\n};\n", 7 | "uid": "acf81498-3d81-11e8-a92a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/takeRight[acf5c95e-3d81-11e8-8039-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "takeRight", 4 | "dontautoexpand" : true, 5 | "name" : "Returns an array with n elements removed from the end.", 6 | "snippet": "const takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length);\n", 7 | "uid": "acf5c95e-3d81-11e8-8039-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/takeWhile[ad00b3a8-3d81-11e8-aee3-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "takeWhile", 4 | "dontautoexpand" : true, 5 | "name" : "Removes elements in an array until the passed function returns `true`. Returns the removed elements.", 6 | "snippet": "const takeWhile = (arr, func) => {\n for (let i of arr.keys()) if (func(arr[i])) return arr.slice(0, i);\n return arr;\n};\n", 7 | "uid": "ad00b3a8-3d81-11e8-aee3-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/take[acf3f5de-3d81-11e8-8a21-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "take", 4 | "dontautoexpand" : true, 5 | "name" : "Returns an array with n elements removed from the beginning.", 6 | "snippet": "const take = (arr, n = 1) => arr.slice(0, n);\n", 7 | "uid": "acf3f5de-3d81-11e8-8a21-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/throttle[acf76688-3d81-11e8-a049-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "throttle", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a throttled function that only invokes the provided function at most once per every `wait` milliseconds", 6 | "snippet": "const throttle = (fn, wait) => {\n let inThrottle, lastFn, lastTime;\n return function() {\n const context = this,\n args = arguments;\n if (!inThrottle) {\n fn.apply(context, args);\n lastTime = Date.now();\n inThrottle = true;\n } else {\n clearTimeout(lastFn);\n lastFn = setTimeout(function() {\n if (Date.now() - lastTime >= wait) {\n fn.apply(context, args);\n lastTime = Date.now();\n }\n }, wait - (Date.now() - lastTime));\n }\n };\n};\n", 7 | "uid": "acf76688-3d81-11e8-a049-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/timeTaken[acf48d1e-3d81-11e8-913a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "timeTaken", 4 | "dontautoexpand" : true, 5 | "name" : "Measures the time taken by a function to execute.", 6 | "snippet": "const timeTaken = callback => {\n console.time('timeTaken');\n const r = callback();\n console.timeEnd('timeTaken');\n return r;\n};\n", 7 | "uid": "acf48d1e-3d81-11e8-913a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/times[ad011674-3d81-11e8-8a29-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "times", 4 | "dontautoexpand" : true, 5 | "name" : "Iterates over a callback `n` times", 6 | "snippet": "const times = (n, fn, context = undefined) => {\n let i = 0;\n while (fn.call(context, i) !== false && ++i < n) {}\n};\n", 7 | "uid": "ad011674-3d81-11e8-8a29-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/toCamelCase[acfa9ac6-3d81-11e8-8114-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "toCamelCase", 4 | "dontautoexpand" : true, 5 | "name" : "Converts a string to camelcase.", 6 | "snippet": "const toCamelCase = str => {\n let s =\n str &&\n str\n .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)\n .map(x => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase())\n .join('');\n return s.slice(0, 1).toLowerCase() + s.slice(1);\n};\n", 7 | "uid": "acfa9ac6-3d81-11e8-8114-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/toCurrency[ad009bf4-3d81-11e8-b561-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "toCurrency", 4 | "dontautoexpand" : true, 5 | "name" : "Take a number and return specified currency formatting.", 6 | "snippet": "const toCurrency = (n, curr, LanguageFormat = undefined) =>\n Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);\n", 7 | "uid": "ad009bf4-3d81-11e8-b561-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/toDecimalMark[acfd72c6-3d81-11e8-b13a-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "toDecimalMark", 4 | "dontautoexpand" : true, 5 | "name" : "Use `toLocaleString()` to convert a float-point arithmetic to the [Decimal mark](https://en.wikipedia.org/wiki/Decimal_mark) form. It makes a comma separated string from a number.", 6 | "snippet": "", 7 | "uid": "acfd72c6-3d81-11e8-b13a-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/toKebabCase[ad002ff4-3d81-11e8-a624-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "toKebabCase", 4 | "dontautoexpand" : true, 5 | "name" : "Converts a string to kebab case.", 6 | "snippet": "const toKebabCase = str =>\n str &&\n str\n .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)\n .map(x => x.toLowerCase())\n .join('-');\n", 7 | "uid": "ad002ff4-3d81-11e8-a624-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/toOrdinalSuffix[ad001030-3d81-11e8-802c-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "toOrdinalSuffix", 4 | "dontautoexpand" : true, 5 | "name" : "Adds an ordinal suffix to a number.", 6 | "snippet": "const toOrdinalSuffix = num => {\n const int = parseInt(num),\n digits = [int % 10, int % 100],\n ordinals = ['st', 'nd', 'rd', 'th'],\n oPattern = [1, 2, 3, 4],\n tPattern = [11, 12, 13, 14, 15, 16, 17, 18, 19];\n return oPattern.includes(digits[0]) && !tPattern.includes(digits[1])\n ? int + ordinals[digits[0] - 1]\n : int + ordinals[3];\n};\n", 7 | "uid": "ad001030-3d81-11e8-802c-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/toSafeInteger[acf3dd74-3d81-11e8-9dc7-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "toSafeInteger", 4 | "dontautoexpand" : true, 5 | "name" : "Converts a value to a safe integer.", 6 | "snippet": "const toSafeInteger = num =>\n Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER));\n", 7 | "uid": "acf3dd74-3d81-11e8-9dc7-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/toSnakeCase[acf53586-3d81-11e8-ab76-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "toSnakeCase", 4 | "dontautoexpand" : true, 5 | "name" : "Converts a string to snake case.", 6 | "snippet": "const toSnakeCase = str =>\n str &&\n str\n .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)\n .map(x => x.toLowerCase())\n .join('_');\n", 7 | "uid": "acf53586-3d81-11e8-ab76-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/toggleClass[acfaf44c-3d81-11e8-a0cb-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "toggleClass", 4 | "dontautoexpand" : true, 5 | "name" : "Toggle a class for an element.", 6 | "snippet": "const toggleClass = (el, className) => el.classList.toggle(className);\n", 7 | "uid": "acfaf44c-3d81-11e8-a0cb-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/tomorrow[acf7f3c8-3d81-11e8-aff1-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "tomorrow", 4 | "dontautoexpand" : true, 5 | "name" : "Results in a string representation of tomorrow's date.", 6 | "snippet": "const tomorrow = (long = false) => {\n let t = new Date();\n t.setDate(t.getDate() + 1);\n const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(\n t.getDate()\n ).padStart(2, '0')}`;\n return !long ? ret : `${ret}T00:00:00`;\n};\n", 7 | "uid": "acf7f3c8-3d81-11e8-aff1-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/transform[acf3a018-3d81-11e8-a6f2-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "transform", 4 | "dontautoexpand" : true, 5 | "name" : "Applies a function against an accumulator and each key in the object (from left to right).", 6 | "snippet": "const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);\n", 7 | "uid": "acf3a018-3d81-11e8-a6f2-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/truncateString[acf8ce68-3d81-11e8-9d1b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "truncateString", 4 | "dontautoexpand" : true, 5 | "name" : "Truncates a string up to a specified length.", 6 | "snippet": "const truncateString = (str, num) =>\n str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;\n", 7 | "uid": "acf8ce68-3d81-11e8-9d1b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/truthCheckCollection[acf6d006-3d81-11e8-b97f-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "truthCheckCollection", 4 | "dontautoexpand" : true, 5 | "name" : "Checks if the predicate (second argument) is truthy on all elements of a collection (first argument).", 6 | "snippet": "const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]);\n", 7 | "uid": "acf6d006-3d81-11e8-b97f-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/unary[acf99ae8-3d81-11e8-a58e-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "unary", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a function that accepts up to one argument, ignoring any additional arguments.", 6 | "snippet": "const unary = fn => val => fn(val);\n", 7 | "uid": "acf99ae8-3d81-11e8-a58e-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/uncurry[ad032ea8-3d81-11e8-8864-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "uncurry", 4 | "dontautoexpand" : true, 5 | "name" : "Uncurries a function up to depth `n`.", 6 | "snippet": "const uncurry = (fn, n = 1) => (...args) => {\n const next = acc => args => args.reduce((x, y) => x(y), acc);\n if (n > args.length) throw new RangeError('Arguments too few!');\n return next(fn)(args.slice(0, n));\n};\n", 7 | "uid": "ad032ea8-3d81-11e8-8864-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/unescapeHTML[acf98e86-3d81-11e8-8300-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "unescapeHTML", 4 | "dontautoexpand" : true, 5 | "name" : "Unescapes escaped HTML characters.", 6 | "snippet": "const unescapeHTML = str =>\n str.replace(\n /&|<|>|'|"/g,\n tag =>\n ({\n '&': '&',\n '<': '<',\n '>': '>',\n ''': \"'\",\n '"': '\"'\n }[tag] || tag)\n );\n", 7 | "uid": "acf98e86-3d81-11e8-8300-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/unflattenObject[acf4cdec-3d81-11e8-8980-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "unflattenObject", 4 | "dontautoexpand" : true, 5 | "name" : "Unlatten an object with the paths for keys.", 6 | "snippet": "const unflattenObject = obj =>\n Object.keys(obj).reduce((acc, k) => {\n if (k.indexOf('.') !== -1) {\n const keys = k.split('.');\n Object.assign(\n acc,\n JSON.parse(\n '{' +\n keys.map((v, i) => (i !== keys.length - 1 ? `\"${v}\":{` : `\"${v}\":`)).join('') +\n obj[k] +\n '}'.repeat(keys.length)\n )\n );\n } else acc[k] = obj[k];\n return acc;\n }, {});\n", 7 | "uid": "acf4cdec-3d81-11e8-8980-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/unfold[ad028f74-3d81-11e8-91d3-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "unfold", 4 | "dontautoexpand" : true, 5 | "name" : "Builds an array, using an iterator function and an initial seed value.", 6 | "snippet": "const unfold = (fn, seed) => {\n let result = [],\n val = [null, seed];\n while ((val = fn(val[1]))) result.push(val[0]);\n return result;\n};\n", 7 | "uid": "ad028f74-3d81-11e8-91d3-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/unionBy[acf9d6ca-3d81-11e8-b6eb-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "unionBy", 4 | "dontautoexpand" : true, 5 | "name" : "Returns every element that exists in any of the two arrays once, after applying the provided function to each array element of both.", 6 | "snippet": "const unionBy = (a, b, fn) => {\n const s = new Set(a.map(v => fn(v)));\n return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))]));\n};\n", 7 | "uid": "acf9d6ca-3d81-11e8-b6eb-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/unionWith[ad03a268-3d81-11e8-89f4-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "unionWith", 4 | "dontautoexpand" : true, 5 | "name" : "Returns every element that exists in any of the two arrays once, using a provided comparator function.", 6 | "snippet": "const unionWith = (a, b, comp) =>\n Array.from(new Set([...a, ...b.filter(x => a.findIndex(y => comp(x, y)) === -1)]));\n", 7 | "uid": "ad03a268-3d81-11e8-89f4-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/union[acf8a5a2-3d81-11e8-a736-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "union", 4 | "dontautoexpand" : true, 5 | "name" : "Returns every element that exists in any of the two arrays once.", 6 | "snippet": "const union = (a, b) => Array.from(new Set([...a, ...b]));\n", 7 | "uid": "acf8a5a2-3d81-11e8-a736-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/uniqueElements[acf55c8a-3d81-11e8-b1f9-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "uniqueElements", 4 | "dontautoexpand" : true, 5 | "name" : "Returns all unique values of an array.", 6 | "snippet": "const uniqueElements = arr => [...new Set(arr)];\n", 7 | "uid": "acf55c8a-3d81-11e8-b1f9-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/untildify[acfe70f4-3d81-11e8-84b2-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "untildify", 4 | "dontautoexpand" : true, 5 | "name" : "Converts a tilde path to an absolute path.", 6 | "snippet": "const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`);\n", 7 | "uid": "acfe70f4-3d81-11e8-84b2-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/unzipWith[acf7e5b8-3d81-11e8-b70b-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "unzipWith", 4 | "dontautoexpand" : true, 5 | "name" : "Creates an array of elements, ungrouping the elements in an array produced by [zip](#zip) and applying the provided function.", 6 | "snippet": "const unzipWith = (arr, fn) =>\n arr\n .reduce(\n (acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc),\n Array.from({\n length: Math.max(...arr.map(x => x.length))\n }).map(x => [])\n )\n .map(val => fn(...val));\n", 7 | "uid": "acf7e5b8-3d81-11e8-b70b-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/unzip[ad02bca4-3d81-11e8-a2a8-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "unzip", 4 | "dontautoexpand" : true, 5 | "name" : "Creates an array of arrays, ungrouping the elements in an array produced by [zip](#zip).", 6 | "snippet": "const unzip = arr =>\n arr.reduce(\n (acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc),\n Array.from({\n length: Math.max(...arr.map(x => x.length))\n }).map(x => [])\n );\n", 7 | "uid": "ad02bca4-3d81-11e8-a2a8-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/validateNumber[acfe2950-3d81-11e8-925e-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "validateNumber", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the given value is a number, `false` otherwise.", 6 | "snippet": "const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;\n", 7 | "uid": "acfe2950-3d81-11e8-925e-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/without[acf739ec-3d81-11e8-9e06-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "without", 4 | "dontautoexpand" : true, 5 | "name" : "Filters out the elements of an array, that have one of the specified values.", 6 | "snippet": "const without = (arr, ...args) => arr.filter(v => !args.includes(v));\n", 7 | "uid": "acf739ec-3d81-11e8-9e06-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/words[acf4be1a-3d81-11e8-9585-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "words", 4 | "dontautoexpand" : true, 5 | "name" : "Converts a given string into an array of words.", 6 | "snippet": "const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean);\n", 7 | "uid": "acf4be1a-3d81-11e8-9585-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/xProd[acf70cb0-3d81-11e8-bb79-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "xProd", 4 | "dontautoexpand" : true, 5 | "name" : "Creates a new array out of the two supplied by creating each possible pair from the arrays.", 6 | "snippet": "const xProd = (a, b) => a.reduce((acc, x) => acc.concat(b.map(y => [x, y])), []);\n", 7 | "uid": "acf70cb0-3d81-11e8-bb79-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/yesNo[acf36a1a-3d81-11e8-ad46-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "yesNo", 4 | "dontautoexpand" : true, 5 | "name" : "Returns `true` if the string is `y`/`yes` or `false` if the string is `n`/`no`.", 6 | "snippet": "const yesNo = (val, def = false) =>\n /^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def;\n", 7 | "uid": "acf36a1a-3d81-11e8-ad46-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/zipObject[acffaff0-3d81-11e8-836e-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "zipObject", 4 | "dontautoexpand" : true, 5 | "name" : "Given an array of valid property identifiers and an array of values, return an object associating the properties to the values.", 6 | "snippet": "const zipObject = (props, values) =>\n props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {});\n", 7 | "uid": "acffaff0-3d81-11e8-836e-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/zipWith[acf56ac2-3d81-11e8-abac-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "zipWith", 4 | "dontautoexpand" : true, 5 | "name" : "Creates an array of elements, grouped based on the position in the original arrays and using function as the last value to specify how grouped values should be combined.", 6 | "snippet": "const zipWith = (...array) => {\n const fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined;\n return Array.from(\n { length: Math.max(...array.map(a => a.length)) },\n (_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i]))\n );\n};\n", 7 | "uid": "acf56ac2-3d81-11e8-abac-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/zip[acf5f348-3d81-11e8-b9fd-acde48001122].json: -------------------------------------------------------------------------------- 1 | { 2 | "alfredsnippet" : { 3 | "keyword" : "zip", 4 | "dontautoexpand" : true, 5 | "name" : "Creates an array of elements, grouped based on the position in the original arrays.", 6 | "snippet": "const zip = (...arrays) => {\n const maxLength = Math.max(...arrays.map(x => x.length));\n return Array.from({ length: maxLength }).map((_, i) => {\n return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]);\n });\n};\n", 7 | "uid": "acf5f348-3d81-11e8-b9fd-acde48001122" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lslvxy/30-seconds-of-code-alfredsnippets/2c1f201ab3c17ed29123e65d8afc9b728c7f2971/icon.png -------------------------------------------------------------------------------- /index.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: UTF-8 -*- 3 | 4 | import re 5 | import sys 6 | import os,glob 7 | import uuid 8 | import zipfile 9 | import shutil 10 | 11 | 12 | path="./" 13 | os.chdir(path) 14 | shutil.rmtree('dist') 15 | os.mkdir('dist') 16 | for filename in os.listdir("./30-seconds-of-code/snippets"): 17 | file = open("./30-seconds-of-code/snippets/"+filename,'r',-1,"UTF-8") 18 | i=1 19 | title='' 20 | keyword='' 21 | codeline=0 22 | titleline=3 23 | content='' 24 | end=0 25 | uuidstr=str(uuid.uuid1()) 26 | for line in file.readlines(): 27 | if i==1: 28 | keyword=line.replace("### ",'') 29 | if keyword=="anagrams\n": 30 | titleline=5 31 | if i==titleline: 32 | title=line 33 | if line=='```js\n' and codeline==0 and end==0: 34 | codeline=i 35 | if line=='```\n' and end==0 : 36 | end=1 37 | if end==0 and i>codeline and codeline>0: 38 | content+=line.replace('\n','\\n') 39 | i+=1 40 | 41 | output = open('./dist/'+keyword.replace("\n","")+'['+uuidstr+'].json', 'w+') 42 | output.write('{\n') 43 | output.write(' "alfredsnippet" : {\n' ) 44 | output.write(' "keyword" : "' + keyword.replace("\n","") + '",\n') 45 | output.write(' "dontautoexpand" : true,\n' ) 46 | output.write(' "name" : "' + title.replace("\n","") + '",\n') 47 | output.write(' "snippet": "' + content.replace("\n","").replace('"','\\"')+ '",\n') 48 | output.write(' "uid": "' + uuidstr+ '"\n') 49 | output.write(' }\n'); 50 | output.write('}\n'); 51 | output.close( ) 52 | 53 | 54 | z = zipfile.ZipFile("3sc.alfredsnippets", 'w') 55 | z.write("./icon.png") 56 | path2="./dist" 57 | os.chdir(path2) 58 | testdir='.' 59 | for d in os.listdir(): 60 | z.write(testdir+os.sep+d) 61 | z.close() --------------------------------------------------------------------------------