Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
@sojs-coder
sojs-coder
Follow
View sojs-coder's full-sized avatar
💭
coding

SoJS coder sojs-coder

💭
coding
Full stack dev with 6+ years of experience.Feel free to contact me with suggestions, comments, or work you want me to do.

Highlights

  • Pro

Block or report sojs-coder

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more aboutblocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more aboutreporting abuse.

Report abuse
sojs-coder/README.md

Professional fullstack dev since 2017

Quick access

json2array

Convert a JSON object to an array

Usage:

json2array({"thing1":{"key1":"value"},"thing2":{"otherKey":"otherVal"}});[{"key1":"value","key":"thing1"},{"otherKey":"otherVal","key":"otherVal"}]

functionjson2array(json){varresult=[];varkeys=Object.keys(json);keys.forEach(function(key){varendJSON=json[key];endJSON.key=keyresult.push(endJSON);});returnresult;}

SumArrays

Add two vectors togeth

functionsumArrays(...arrays){constn=arrays.reduce((max,xs)=>Math.max(max,xs.length),0);constresult=Array.from({length:n});returnresult.map((_,i)=>arrays.map(xs=>xs[i]||0).reduce((sum,x)=>sum+x,0));}

rand

Generates a random number X digits long

functionrand(digits){returnMath.floor(Math.random()*parseInt('8'+'9'.repeat(digits-1))+parseInt('1'+'0'.repeat(digits-1)));}

isEmptyObject

Checks to see if an object is equal to{}

functionisEmptyObject(obj){for(varkeyinobj){if(obj.hasOwnProperty(key))returnfalse;}returntrue;}

uid

Vanilla JS generate UID

constuid=()=>{letd=newDate().getTime(),d2=((typeofperformance!=='undefined')&&performance.now&&(performance.now()*1000))||0;return'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,c=>{letr=Math.random()*16;if(d>0){r=(d+r)%16|0;d=Math.floor(d/16);}else{r=(d2+r)%16|0;d2=Math.floor(d2/16);}return(c=='x' ?r :(r&0x7|0x8)).toString(16);});};

randRange

Generates a random number in range

functionrandRange(min,max){returnMath.random()*(max-min)+min;}

PinnedLoading

  1. MultisnakeMultisnakePublic

    A multiplayer snake game.

    JavaScript 3 4

  2. AnvilAnvilPublic

    Forge HTML games

    JavaScript 2 1

  3. SoAuthSoAuthPublic

    SoAuth is a powerful and secure authentication solution that offers serverless capabilities, making it easy to integrate into any project.

    JavaScript 1

  4. SoIdeasSoIdeasPublic

    Code idea generator tracks completion & rates difficulty. Generates ideas based on difficulty and tracks popularity.

    JavaScript 1

  5. Space-WarsSpace-WarsPublic

    Defend your fly zone from alien invaders, rack up points and escape swarms with your trusty radar. Comment your high scores and have fun!

    JavaScript 1


[8]ページ先頭

©2009-2025 Movatter.jp