blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 132 | path stringlengths 3 236 | src_encoding stringclasses 29
values | length_bytes int64 8 7.94M | score float64 2.52 5.72 | int_score int64 3 5 | detected_licenses listlengths 0 142 | license_type stringclasses 2
values | text stringlengths 8 7.94M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
55bb70c5fba85a69df16be70f2266c458050be9d | JavaScript | drusin/xplosive-phaser | /src/yanecs/System.js | UTF-8 | 399 | 2.765625 | 3 | [] | no_license | export default class System {
constructor(...componentNames) {
this._componentNames = componentNames;
}
get componentNames() {
return this._componentNames;
}
processAll(entities, delta, time) {
entities.forEach(entity => this.process(entity, delta, time));
}
process(entity, delta, time) {
console.e... | true |
1eb2f03e5cc6f101d86b19ae58303050b1b2aea6 | JavaScript | FilipeFaralhe/Curso-Origamid-JS | /javascript-assincrono/exercicios/exeFetch/exeFetch01/script.js | UTF-8 | 527 | 3.65625 | 4 | [] | no_license | // Utilizando a API https://viacep.com.br/ws/${CEP}/json/
// crie um formulário onde o usuário pode digitar o cep
// e o endereço completo é retornado ao clicar em buscar
function search(event) {
event.preventDefault();
const input = document.querySelector('input').value;
fetch(`https:viacep.com.br/ws/${inp... | true |
7484fad072cb992570adfbef54cc2c6ea37fe910 | JavaScript | ShamanthK/WalmartPOC | /client/src/components/FinancialPerformance.js | UTF-8 | 2,369 | 2.546875 | 3 | [] | no_license | import React, { Component} from 'react';
import Logoimg from "./superscript.JPG";
class FinancialPerformance extends Component {
constructor(props) {
super(props);
this.state = {
values: [],
}
}
componentDidMount() {
fetch('http://localhost:5000/api/items... | true |
52e8be3d7dee44ed4ae53a40cd1cdf71da1818ee | JavaScript | jin3378s/todolist-saga | /src/actions/index.js | UTF-8 | 724 | 2.53125 | 3 | [] | no_license | import axios from 'axios';
export const MAKE_CARD = 'MAKE_CARD';
export const GET_CARD = 'GET_CARD';
export const DELETE_CARD = 'DELETE_CARD';
export const GET_CARD_SUCCESS = 'GET_CARD_SUCCESS';
export const GET_CARD_FAILURE = 'GET_CARD_FAILURE';
export function makeCard (data){
return {
type : MAKE_CARD,
... | true |
74fba28a3d6e32e100aa692c339a3cfadc5a9644 | JavaScript | lauramadsen/video_votes | /app.js | UTF-8 | 4,411 | 2.609375 | 3 | [] | no_license | var express = require('express');
var app = express();
var MongoClient = require('mongodb').MongoClient
, assert = require('assert')
, ObjectID = require('mongodb').ObjectID
, db_url = 'mongodb://localhost:27017/videos';
var create_video = function(user_id, url, callback) {
MongoClient.connect(db_url, function (e... | true |
a6288d77000c5c5b365e1e39df46f77825204a39 | JavaScript | cbennett07/mock_gmail | /src/Components/EmailDetail.js | UTF-8 | 2,451 | 2.671875 | 3 | [] | no_license | import React from "react";
import axios from "axios";
class EmailDetail extends React.Component {
constructor(props) {
super(props);
this.state = this.getInitialState()
//this.handleComposeInputChange = this.handleComposeInputChange.bind(this)
}
getInitialState() {
return ... | true |
c5ff8ad9871760ea8ccd3847c103bc316ab916e4 | JavaScript | timothy-janssen/Recast.AI- | /Binary Tree/testTree.js | UTF-8 | 1,926 | 3.34375 | 3 | [] | no_license | var Node = require('./Tree');
var assert = require('assert');
//Create nodes using simple, small integers
var test1RootNode = new Node(0),
test1Node1 = new Node(1),
test1Node2 = new Node(2),
test1Node3 = new Node(3),
test1Node4 = new Node(4),
test1Node5 = new Node(5),
test1Node6 = new Node(6),
... | true |
99770cf69f0f86e8b2d1f76a9e82e8eb0291180f | JavaScript | NithyaGR/PerScholasWorks | /SoftwareEngineering/JavaScriptPractice/Week3/Day4/AfternoonLab1.js | UTF-8 | 627 | 3.328125 | 3 | [] | no_license |
// Create an Animal class.
// The class will have name, age, color, legs, superPower attributes
// Create two objects of this class - both with a unique superPower
// create three methods for this class - include one method named userSuperPower()
// Create two objects for this class
class Animal{
constructor(name, a... | true |
b570ad80629a6984bb153a50a88645710c504869 | JavaScript | BeeMargarida/CGRA_FEUP | /tp/MyFish.js | UTF-8 | 2,052 | 2.828125 | 3 | [] | no_license | var degToRad = Math.PI / 180.0;
function MyFish(scene, x,y) {
CGFobject.call(this,scene);
this.triangle = new MyEqualSidedTriangle(this.scene,0,1,0,0.866);
this.quad = new MyQuad(this.scene,0,1,0,1);
this.x = x;
this.y = y;
this.z = -10;
this.lastTime = 0;
this.firstTime = 0;
var d = new Date();
... | true |
a02cdbc85b28aa7ef6ac40e2e7c8d7a721c6ee5c | JavaScript | dannyirwin/FCC-Markdown-Previewer | /script.js | UTF-8 | 891 | 3.484375 | 3 | [] | no_license | const editor = document.getElementById("editor");
const preview = document.getElementById("preview");
const defaultInputText = "**Welcome!**\n\n This is a Markdown Previewer App. You can write your text with the typical Markdown syntax and it will be rendered in real time! \n\nSome Examples:\n\nAn H1 style Header\n===... | true |
6f22965174018e4d6171168555bc38bcf93d5efc | JavaScript | azemel/itstep-js | /Abstract-1/functions.js | UTF-8 | 2,314 | 3.734375 | 4 | [] | no_license | // Набор инструкции -
// Фрагмент кода к которому можно обратиться
// Именованный фрагмент кода который может принимать и возвращаться значения
// (чистая функция FP) , процедура , (метод ООП)
// Имя + параметры . Обращаться из разных мест программы
// procedure param1 param2
// 1
// 2
// 3
// 4
// ??... | true |
0fdc09096df0ad3c7bc66bcc8ab3f03baf38a1b8 | JavaScript | jwbenedek/Front_Dev_JW | /scripts/script.js | UTF-8 | 806 | 3.0625 | 3 | [] | no_license | /* STICKY HEADER, bron: https://www.w3schools.com/howto/howto_js_sticky_header.asp */
window.onscroll = function() {myFunction()};
// Get the header
var header = document.getElementById("myHeader");
// Get the offset position of the navbar
var sticky = header.offsetTop;
// Add the sticky class to the header when yo... | true |
cadf861260e7ee9d9f1e19555eb11aa916ced324 | JavaScript | paulmccarthy/codewars | /kata/the-hashtag-generator/tests/unit-test-index.js | UTF-8 | 1,426 | 3.296875 | 3 | [
"MIT"
] | permissive | const expect = require('chai').expect;
const generateHashtag = require('../index').generateHashtag;
describe('Unit tests for kata/the-hashtag-generator', function() {
it('should return false for an empty string', function(done) {
const result = generateHashtag('');
expect(result).to.be.false;
... | true |
0b79b3132c5287c1ef42cce2ebecc7798f25744f | JavaScript | snombela/rabbit-hole-game | /index.js | UTF-8 | 329 | 2.671875 | 3 | [] | no_license | window.onload = function() {
game = new Game("#canvas");
document.querySelector("#start-buttom").onclick = function() {
document.querySelector("#start-container").style.display = "none";
document.querySelector("#canvas").style.display = "block";
startGame()
}
};
function startGame()... | true |
cde7dbe3dd2348b2ce285132247c40345579e191 | JavaScript | SeptEarlyMorning/leetcode | /1646. 获取生成数组中的最大值/index.js | UTF-8 | 347 | 3.109375 | 3 | [] | no_license | /**
* @param {number} n
* @return {number}
*/
var getMaximumGenerated = function(n) {
const arr = [0, 1];
let maxNum = 0;
for (let i = 0; i <= n >> 1; ++i) {
arr[2 * i] = arr[i];
if (2 * i + 1 <= n) {
arr[2 * i + 1] = arr[i] + arr[i + 1];
maxNum = Math.max(maxNum, arr[i] + arr[i + 1]);
... | true |
54a9c16c75b7b611be05ef568d9aee3bea77a9a0 | JavaScript | wilddamon/Calendar-Mailer | /javascript/rruleformatter.js | UTF-8 | 3,694 | 2.625 | 3 | [] | no_license |
/**
* @fileoverview An RRULE utility class.
*/
goog.provide('calendarmailer.RRuleFormatter');
goog.require('goog.string.StringBuffer');
/**
* The RRule util class.
* @constructor
*/
calendarmailer.RRuleFormatter = function() {
};
goog.addSingletonGetter(calendarmailer.RRuleFormatter);
/**
* String transfo... | true |
2eeb7bce251dcc8af8d7cfbf88704f270cbd649f | JavaScript | waqasbaj/w1_d3_sales_tax | /sales_tax.js | UTF-8 | 1,704 | 3.609375 | 4 | [] | no_license | var salesTaxRates = {
AB: 0.05,
BC: 0.12,
SK: 0.10
};
var companySalesData = [
{
name: "Telus",
province: "BC",
sales: [ 100, 200, 400 ]
},
{
name: "Bombardier",
province: "AB",
sales: [ 80, 20, 10, 100, 90, 500 ]
},
{
name: "Telus",
province: "SK",
sales: [ 500, 100... | true |
1932ed0330d236922b32b8bb4dbb950e1f30f64a | JavaScript | aashishuppalui/React-Practice | /src/components/NameList.js | UTF-8 | 1,096 | 3.515625 | 4 | [] | no_license | import React from "react";
import Person from "./Person";
function NameList() {
// const names = ["Bruce", "Clark", "Dianna"];
const persons = [
{
id: 1,
name: "Bruce",
age: 30,
skill: "React"
},
{
id: 2,
name: "CLark",
age: 25,
skill: "React Native"
... | true |
ba638ac3f0fd0d3b9853fedc2a96a9697cce3661 | JavaScript | cul-2016/quiz | /server/lib/getTotalScoresAndTrophies.js | UTF-8 | 744 | 2.53125 | 3 | [] | no_license | var query = require('./query');
var queries = require('./queries.json');
/**
* Represents a function that returns the total scores and trophies for a leaderboard.
* @param {object} client - postgres database client
* @param {string} module_id - module id
* @param {function} callback - a callback function
*/
func... | true |
159ef9daf02fdc5758ac4cb6ecf96c01a7a50965 | JavaScript | Nakurai/logical_engine | /collection.js | UTF-8 | 1,383 | 3.109375 | 3 | [] | no_license | "use strict";
var q = require("q");
/**
A structure containing meta information about a concept
for each predicates, a value is filled
Methods specific to collection are then used to deduce things
ex: {name:"is", value:"thing"} => a method can grab every parents to create a tree
*/
function Collection... | true |
ab82d77ca972f899ca14a1c197b73c182a690635 | JavaScript | ewecke/exercises | /35-PB-arrays-pt3/ex-35-edgar.js | UTF-8 | 2,515 | 4.21875 | 4 | [] | no_license | "use strict";
//Q1
console.log("**1. Where Have My Four Letter Words Gone?**");
function isFourLetters(str) {
let myArray = [];
for (let i = 0; i < str.length; i++) {
if (str[i].length === 4) {
myArray.push(str[i]);
}
}
return myArray;
}
console.log(isFourLetters(["John",... | true |
0f30b7126d961d164c70b27ca4b39bfc9223996d | JavaScript | nbento/mute000 | /js/main.js | UTF-8 | 1,235 | 2.75 | 3 | [] | no_license | /*
GLOBLSPACE:
HolderIds
elemGlobalSpace
*/
//====================
//....................
function _cons ( messg ) { console.log( messg ); }
//====================
/*
$(document).ready( function()
{
console.log("document).ready... READY!!!");
//....................
//console.log("WIDTH:::" + window.innerWidt... | true |
aead820f275e6d4ce0fdfded3cc67c0be4fe1bba | JavaScript | 13387555843/text | /day12/5.js | UTF-8 | 259 | 3.28125 | 3 | [] | no_license | /*
变量提升:var 和function
var n;
function fn =AAAFFF111
*/
console.log(n);
var n=3;
fn();
function fn(){
var x=6;
console.log(x)
}
var a = 0;
if (true) {
a = 1;
function a() { }
a = 21;
console.log(a);
}
console.log(a); | true |
0c0f2164f9509219c40c615c6fe0677fa85ce668 | JavaScript | canjs/can-query-logic | /src/serializers/comparisons-test.js | UTF-8 | 1,513 | 2.796875 | 3 | [
"MIT"
] | permissive | var QUnit = require("steal-qunit");
var comparisons = require("./comparisons");
var canReflect = require("can-reflect");
var ValuesNot = require("../types/values-not");
QUnit.module("can-query-logic/serializers/comparisons");
QUnit.test("hydrate and serialize with custom types that work with operators", function(asse... | true |
ca9ee8c19599de023f17b38d8d15e2bef6f69cca | JavaScript | samhinton88/code-fold | /src/utils/skim.js | UTF-8 | 349 | 3.171875 | 3 | [
"MIT"
] | permissive | export const skim = (obj, depth = 0) => {
if (depth === 3) {
return null;
}
const contribution = Object.entries(obj).reduce(
(acc, [key, val]) => {
acc[key] =
typeof val === "object" && val !== null ? skim(val, depth + 1) : val;
return acc;
},
Array.isArray(obj) ? [] : {}
)... | true |
406bec8c0cbf35503336dab0f0a4cc218eb8b130 | JavaScript | JavierAndresChireno/fit-journal-client | /src/Services/ExerciseService.js | UTF-8 | 4,526 | 2.59375 | 3 | [] | no_license | import React from 'react';
import CONFIG from '../config';
import TokenService from '../Services/TokenService';
import FormatService from './FormatService';
const ExerciseService = {
getAllExercises() {
return fetch(`${CONFIG.API_ENDPOINT}exercises/`, {
method: 'GET',
headers: {
'Content-Type'... | true |
8e527cbb786ff6bca4882448c45183a7190c6364 | JavaScript | uraid-dev/uraid_web | /web/js/util/RequestUtil.js | UTF-8 | 3,499 | 2.828125 | 3 | [] | no_license | //数据请求:这里使用的是des加密算法,先将原始数据进行加密传递给服务器端。之后再将返回的数据进行解密操作
function getData(strUrl, requestObj, responseObj, deferred) {
var strJson = angular.toJson(requestObj);
console.log("请求的参数:"+strJson);
//加密方法;三个key 只要和后端的商量好就可以了,随便填写什么。
//var enResult = strEnc(strJson,"e036hlqtculakx38tjw2u9gs","yvo0sovt414fakqwv... | true |
74379f8c41da473b40636bf8a2517e9b1670f5e8 | JavaScript | wally-wally/TIL | /06_js/04_algorithm/leetcode/Easy/0929_Unique Email Addresses.js | UTF-8 | 1,023 | 3.40625 | 3 | [] | no_license | const numUniqueEmails = (emails) => {
// emails의 길이가 1이면 무조건 1로 return
if (emails.length === 1) {
return 1;
}
const regenerateEmailAddress = (email) => {
// '@' 기준으로 local name, domain name 분리
let [ localName, domainName ] = email.split('@');
// local name에서 '.' 기호는 모두 제거
localName = local... | true |
bcf9f4edc9036b3189b495e3b8a1185d924abfbd | JavaScript | chewhx/ui8-thegoodlifeblog | /src/components/section/nav.js | UTF-8 | 1,611 | 2.59375 | 3 | [] | no_license | import React, { useState } from 'react'
import brand from '../../assets/logos/brand.svg'
import { Link } from 'react-router-dom'
const Nav = (props) => {
const [state, setState] = useState(true)
console.log("state: " + state)
const show = (x) => {
x.forEach(each => each.style.display = "block");
... | true |
0dbacdc704de29d7b09c5bab5e093e0ac885a403 | JavaScript | johnwu0604/yuze | /server/api/controller/customerController.js | UTF-8 | 6,474 | 2.59375 | 3 | [] | no_license | var FrameUtility = require('../util/frameUtility')
var AmazonUtility = require('../util/amazonUtility')
var MicrosoftUtility = require('../util/microsoftUtility')
var async = require('async')
var Customer = require('../model/customer')
var UUID = require('uuid/v1')
var uuid = ''
var uploadedPhotos = []
var customerId ... | true |
774ba6737295b99d7db284f7ff6e98f51009534a | JavaScript | Braloup/jsweb1.4 | /script.js | UTF-8 | 947 | 3.75 | 4 | [] | no_license | "use strict";
// import some polyfill to ensure everything works OK
import "babel-polyfill"
// import bootstrap's javascript part
import 'bootstrap';
/*
Put the JavaScript code you want below.
*/
// Creating functions for the current date...
let date = new Date();
let year = date.getFullYear();
let month = date.ge... | true |
23a60a3ffe28836a367cdf6afac7a40964f90328 | JavaScript | gourav221b/Form-Validation | /script.js | UTF-8 | 2,754 | 3.078125 | 3 | [] | no_license | // INITIALIZE VARIABLES
const MainForm=document.getElementById('validateForm');
const NameDiv = document.getElementById('nameinput');
const email = document.getElementById('emailinput');
const password = document.getElementById('passwordinput');
const eyeIcon=document.getElementById('eye');
const submitBtn= docum... | true |
da29724c049cf6889e465528247cf41b79bb0fb5 | JavaScript | cwyoder/trib-quiet-rooms | /_blueprint/scripts/js_parser.js | UTF-8 | 2,765 | 2.625 | 3 | [] | no_license | var htmlparser = require('htmlparser2');
var Entities = require('html-entities').AllHtmlEntities;
var url = require('url');
var fs = require('fs')
var args = process.argv.slice(2);
fs.readFile(args[0], 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
var handler = new htmlparser.DomHandl... | true |
e84b77010da6fa63ec728c6611e65cb76a7231a1 | JavaScript | digitradiart/bookshelf-by-ayu | /js/toggle.js | UTF-8 | 308 | 2.71875 | 3 | [] | no_license | const toggle = document.querySelector('#btn-toggle');
const theme = document.querySelector('#theme-link');
toggle.addEventListener('click', function() {
if (theme.getAttribute('href') == 'css/light.css') {
theme.href = 'css/dark.css';
} else {
theme.href = 'css/light.css';
}
}); | true |
8fca8c83a5f6de6b888436abf1f1c90d21f51003 | JavaScript | leiqiang123/leetcode | /.leetcode/80.删除有序数组中的重复项-ii.js | UTF-8 | 451 | 3.078125 | 3 | [] | no_license | /*
* @lc app=leetcode.cn id=80 lang=javascript
*
* [80] 删除有序数组中的重复项 II
*/
// @lc code=start
/**
* @param {number[]} nums
* @return {number}
*/
var removeDuplicates = function(nums) {
if (nums.length <= 2) return nums.length
let low = 2
let fast = 2
while (fast < nums.length) {
if (nums[low - 2] !== ... | true |
d251e1ed08ef079512a228e1f1c54740903ba37f | JavaScript | moiyyadi786/fighting-chopper | /js/app/power.js | UTF-8 | 1,066 | 2.796875 | 3 | [] | no_license | var Gun = function(playerbullets, bulletType, fireAtOnce, scaleX, scaleY, color){
this.playerbullets = playerbullets;
this.bulletType = bulletType;
this.fireAtOnce = fireAtOnce;
this.scaleX = scaleX;
this.scaleY = scaleY;
this.color = color;
}
Gun.prototype.fire = function(){
var previousBullet;
for(var i... | true |
fd075c101cbc30db78aeb7d7b58db7af24d8b0bd | JavaScript | billyhw/w1d4 | /map.js | UTF-8 | 276 | 3.453125 | 3 | [] | no_license | var map = function(array, func) {
var result = [];
for (i of array) {
result.push(func(i));
}
return result;
}
var words = ["ground", "control", "to", "major", "tom"];
var wordCount = map(words, function(word) {
return word.length;
});
console.log(wordCount); | true |
cbaeb6b560de893a9b8975ff7ce595275d43dc50 | JavaScript | nmuldavin/chai-almost | /test.js | UTF-8 | 3,951 | 2.875 | 3 | [] | no_license | var chai = require('chai')
var chaiAlmost = require('./index')
chai.use(chaiAlmost())
var expect = chai.expect
describe('chaiAlmost', function () {
describe('almost method', function () {
describe('with shallow equality', function () {
it('should modify shallow equality checks on numbers to allow default... | true |
315b8a4f4cc162d230ad38e8180dacc543e7e284 | JavaScript | lachenmayer/deno_std | /node/_tools/suites/common/index.js | UTF-8 | 3,880 | 2.6875 | 3 | [
"MIT"
] | permissive | // deno-fmt-ignore-file
// deno-lint-ignore-file
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
/**
* This file is meant as a replacement for the original common/index.js
*
* That file has a lot of node functionality not currently supported, so this is a lite
* version of that file,... | true |
84ff36edac2dc45b3d3d6e0f345e68ab38622e7e | JavaScript | Siddhant-K-code/hackathon-webapp | /src/reducers/appStatus.js | UTF-8 | 224 | 2.53125 | 3 | [
"MIT"
] | permissive | const appStatusReducer = (state = 'offline', action) => {
switch(action.type) {
case 'CHANGE':
state = action.payload;
return state;
default:
return state;
}
};
export default appStatusReducer; | true |
a35b5df3b334b929c27909cd6a24cb1c6963f5dd | JavaScript | arrow767/js-tasks | /random/main.js | UTF-8 | 667 | 3.625 | 4 | [] | no_license | let arr = [];
let calc = {};
//генерируем рнадомное число
function genRandom(max, min) {
return Math.floor(Math.random() * (max - min + 1));
}
//генерируем массив рандомных чисел
function genArray(array, length) {
for (i = 0; i < length; i++) {
array.push(genRandom(10, 1));
}
}
//подсчитыв... | true |
8c8ab83bc825101636c44c5015de62edca23d7c8 | JavaScript | godric7/couchtard | /models/Basic.js | UTF-8 | 1,751 | 2.609375 | 3 | [
"MIT"
] | permissive | "use strict";
var util = require('util');
var uuid = require('node-uuid');
var Model = require('../lib/Model.js');
function Basic() {
Model.apply(this, arguments);
if (!this.id)
this.id = '/'+this._type+'s/'+uuid.v4();
if (!this.created)
this.created = (new Date()).toISOString();
if (!this.updated)
... | true |
aadfeacd06eff4e9a4c0e2c1d44978630cd7f7e0 | JavaScript | gabrielolferrari/drupal-decoupled-graphql | /docroot/themes/custom/react_simple/js/index.js | UTF-8 | 2,165 | 2.765625 | 3 | [] | no_license | // Import not needed because React & ReactDOM are loaded by *.libraries.yml
class ShowNodeContent extends React.Component {
constructor(props) {
super(props);
this.state = { status: 0 };
this.showContent = this.showContent.bind(this);
this.hideContent = this.hideContent.bind(this);
}
showConten... | true |
9ec49067105d862a8debc5281946db647764f68d | JavaScript | bschmitz9/ProTalk | /auth/passportAuth.js | UTF-8 | 2,151 | 2.59375 | 3 | [] | no_license | module.exports = function (passport, FacebookStrategy, config, mongoose){
//create our schema and ask for these items back from FB
var userModel = new mongoose.Schema({
profileID: String,
fullName: String,
profilePic: String
});
var User = mongoose.model('User', userModel);
... | true |
a20358fc1e86738337f4d0a9e7de7779518586e9 | JavaScript | eaperkins34/CuddleCo | /src/Pages/Cats.js | UTF-8 | 1,783 | 2.5625 | 3 | [] | no_license | import React from 'react';
import '../home/Navbar';
import CatTable from '../tables/CatTable';
import "./animal.css"
import APIURL from '../helpers/environment';
class Cats extends React.Component {
constructor(props) {
super(props)
this.state = {
animals: []
};
}
fetc... | true |
7f02d977d3898f895947d10839b96014a75ef97c | JavaScript | igormusic/agentjs | /index.js | UTF-8 | 1,077 | 2.59375 | 3 | [] | no_license | var Stomp = require('stompjs');
var prompt = require('prompt');
var schema = {
properties: {
agents: {
pattern: /^[0-9\s\-]+$/,
message: 'Enter number of agents',
required: true
},
tps: {
pattern: /^[0-9\s\-]+$/,
message: 'Enter number for transactions p... | true |
1e3c4093ae88be1fd34f6844072cc25e05d626b3 | JavaScript | satya-ranjon/my-app | /components/body/CommentForm.js | UTF-8 | 2,170 | 2.6875 | 3 | [] | no_license | import React, { Component } from 'react';
import { Form, Button, Input } from 'reactstrap';
class CommentForm extends Component {
constructor(props) {
super(props);
this.state = {
author: '',
rating: '',
comment: ''
}
this.handleInputChange = this... | true |
69446352a33c9249c85df7674c6dd937ce83cd6a | JavaScript | TadasBalsys/react-e-shop | /src/redux/cart/cart.selectors.js | UTF-8 | 1,412 | 3.046875 | 3 | [] | no_license | import { createSelector } from 'reselect';
// selectCart - Input selector are selector that only returns a piece of the state.
const selectCart = state => state.cart;
// this function returns cartItems
export const selectCartItems = createSelector(
[selectCart],
cart => cart.cartItems
);
// this function ret... | true |
41b622e0c29f80f6f82696676aec5216ac18c013 | JavaScript | zsjun/leetcode | /src/sort/1387_Sort_Integers_by_The_Power_Value/index.js | UTF-8 | 531 | 3.140625 | 3 | [] | no_license | /**
* @param {number} lo
* @param {number} hi
* @param {number} k
* @return {number}
*/
export default (lo, hi, k) => {
if (lo === hi) return lo;
let res = [];
for (let i = lo; i <= hi; i++) {
let count = i;
let number = 0;
while (count !== 1) {
if (count % 2 === 0) {
count = count ... | true |
cebc6b9b7d0b8b13e0ac381a27425833a1fd8740 | JavaScript | Bolboa/image-app-challenge | /server/src/users/controllers/create_user.js | UTF-8 | 1,156 | 2.75 | 3 | [] | no_license | const User = require("../models/User.js");
const Boom = require("boom");
/*
Create a new user or get the user from the database.
*/
exports.create = async (req, h) => {
if (!req.pre.user_details.user.data.name) {
full_name = [req.pre.user_details.user.data.login, ""];
}
else {
// Split name into f... | true |
d1c82731c1fa501509eb9730b4075124d11116e1 | JavaScript | balajinikhil/algorithm-dataStructure | /1.big_O_notation/1.Big-O-Notation/types.js | UTF-8 | 743 | 4.28125 | 4 | [] | no_license | /*1.linear f(n)=n*/
const addUpTo = n => {
let num = 0;
for (let i = 1; i <= n; i++) {
num += i;
}
return num;
};
console.log(`linear: `, addUpTo(10000));
/*2.qudratic f(n) = n^2
print all pairs of n */
const printPairs = n => {
for (let i = 0; i <= n; i++) {
for (let j = 0; j <= n; j++) {
... | true |
dfd33626e05e4fb20779a2fc09d477c59e148401 | JavaScript | baijialiGit/Weather | /js/index.js | UTF-8 | 5,811 | 2.875 | 3 | [] | no_license | $(function(){
//获取城市天气图片的文档 存入tmpPic中
var tmpPic='';
$.ajax({
type:'get',
url:'http://files.heweather.com/condition-code.txt',
dataType:'text',
success:function(e){
tmpPic=e;
},
error:function(err){
console.log(err);
}
})
//默认获取上海的天气信息
getDate('上海');
//点击该城市切换 显示天气
$('.cityContaine... | true |
d3214a997de460c7702de1b8f62c5b72f6f5f7dd | JavaScript | iamnastya007/WebDev_MCS | /JS_course/08_ternary/js/script.js | UTF-8 | 669 | 3.265625 | 3 | [] | no_license | console.log('You are at ' + window.location);
const Image = document.querySelector('.imageBlock');
let answer = prompt("Сколько тебе лет?");
answer = parseInt(answer);
// if (answer<11) {
// Image.style.backgroundImage = "url(img/schenok.jpg)";
// } else if (answer<=17) {
// Image.style.backgroundImage = "url(img/p... | true |
6473151ddfbd1249a774c0af288d04e1e1d705dd | JavaScript | diyanqi/A.C.Station | /static/js/index.js | UTF-8 | 1,561 | 2.65625 | 3 | [] | no_license | `
<div class="mdui-card">
<div class="mdui-card-media">
<img src="card.jpg"/>
<div class="mdui-card-media-covered">
<div class="mdui-card-primary">
<div class="mdui-card-primary-title">Title</div>
<div class="mdui-card-primary-subtitle">Subtitle</div>
</div>
<div class="mdui-card-actions">
<button class="mdui-btn mdui-... | true |
bfe5e2d3993bd6d310d59b5305d23fb3a9d76400 | JavaScript | Polas7/Ejercicio-Guiado-DOM | /js/main.js | UTF-8 | 746 | 2.703125 | 3 | [] | no_license | function translate(){
var titulo= document.getElementById("form-signin-heading");
var email= document.getElementById("inputEmail");
var password= document.getElementById("inputPassword");
var remember= document.getElementsByTagName("span")[0];
var button= document.getElementsByClassName("btn")[0];
... | true |
ab58102105d4f6de095df2a821587dc7f81c6872 | JavaScript | anekpattanakij/EnhanceJSONStringify | /test/enhance-json-stringify.js | UTF-8 | 1,282 | 2.734375 | 3 | [
"MIT"
] | permissive | const assert = require('assert');
const enhanceStringify = require('../');
// Create circular dependency object
let objectA = { variable1: 1, variable2: 2 };
let objectB = { variable1: objectA, variable2: 'two' };
objectA.variable1 = objectB.variable1;
describe('JSONConverterTest', function () {
it('convert circ... | true |
0fcec1e3e5bf6b8f572592b94c7d36459699b468 | JavaScript | StreakYC/live-set | /src/mapWithRemoval.test.js | UTF-8 | 2,154 | 2.796875 | 3 | [
"MIT"
] | permissive | /* @flow */
import mapWithRemoval from './mapWithRemoval';
import LiveSet from '.';
import delay from 'pdelay';
test('works', async () => {
let lsStep;
const lsCleanup = jest.fn();
const ls = new LiveSet({
read: () => new Set([{ x: '1' }, { x: 'one' }]),
listen(setValues, controller) {
setValues(t... | true |
c93ac39915b7210c50446f4cba4bf0a5af64dfab | JavaScript | vfile/vfile-find-up | /lib/index.js | UTF-8 | 7,825 | 2.921875 | 3 | [
"MIT"
] | permissive | /**
* @callback Assert
* Handle a file.
* @param {VFile} file
* File to handle.
* @returns {Result | undefined}
* How to handle this file.
*
* `true` is treated as `INCLUDE`.
*
* @callback Callback
* Callback called when done finding one file.
* @param {Error | undefined} error
* Error.
*
* ... | true |
fbe74bef7c50479f14f0c5d5e691853df3ff5628 | JavaScript | nkshn/spiceroom-proto | /src/store/reducers/cartReducer.js | UTF-8 | 2,402 | 2.828125 | 3 | [] | no_license | import CartItem from '../../model/cartItem';
const initialState = {
products: [],
totalPrice: 0,
}
const cartReducer = (state = initialState, action) => {
switch (action.type) {
case 'ADD_PRODUCT_TO_CART':
let arr = [...state.products];
let price = action.payload.price;
let item = new Car... | true |
9085d9cc218828c14e2584264496b6ad1cb4c6fd | JavaScript | jhans3br/coating-guide | /src/reducers/coating-reducer.js | UTF-8 | 1,443 | 2.546875 | 3 | [] | no_license | import { Coating } from '../actions/coating-actions.js';
const updateCoating = (state, prop, value) => {
let coat = new Coating(state);
coat[prop] = value;
return coat;
};
export default function coatingReducer(state = new Coating(), action) {
switch(action.type) {
case 'SET_COATING_PRODUCT_N... | true |
f438868d70e04fc63890ec8f601b6cab541dabf7 | JavaScript | HebaMostafa123/ShoppingList | /src/App.js | UTF-8 | 2,117 | 3.03125 | 3 | [] | no_license | import { Component } from "react";
import AddBar from "./AddBar";
import "./App.css";
import ItemList from "./ItemList";
// Components
// 1) ItemRow (label+checkbox+edit+delete) function
// 2) ItemsList (list of ItemsRows) function
// 3) AddBar (Text Field + Button) function
// 4) Categories ( Categories List) function... | true |
8f85999033dca07fd5d84968b15b96d022af2fcd | JavaScript | jenasubhadev/website | /src/tests/HomeMain.test.js | UTF-8 | 1,999 | 2.75 | 3 | [] | no_license | import React from "react";
import { render, unmountComponentAtNode } from "react-dom";
import { act } from "react-dom/test-utils";
import { formatOf } from "../components/extras/customFormatters";
import { Descriptors } from "../components/HomeMain";
let container = null;
beforeEach(() => {
// setup a DOM element as... | true |
bdf7a87b9133ad851b3d2a55922347b37fd3ee83 | JavaScript | warbonnet333/goit-js-homework | /module_10/src/index.js | UTF-8 | 1,050 | 2.8125 | 3 | [] | no_license | 'use strict';
import menu from '../src/menu.json';
import './styles.css';
import menuItemTemplate from './templates/menu_item.hbs';
const refs = {
menuList: document.querySelector('.js-menu'),
themeSwitch: document.querySelector('.js-switch-input'),
body: document.querySelector('body'),
};
const Theme = {
LI... | true |
d9c5b63258ebd5b3419d30a1641a48d8f25c7e11 | JavaScript | Rachel-Hofer/CodeWars | /7kyu_mumbling/mumble.js | UTF-8 | 1,000 | 4.125 | 4 | [] | no_license | // Instructions:
// This time no story, no theory. The examples below show you how to write function accum:
// accum("abcd"); // "A-Bb-Ccc-Dddd"
// accum("RqaEzty"); // "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"
// accum("cwAt"); // "C-Ww-Aaa-Tttt"
// My Answer:
function accum(string) {
let splitString = string.sp... | true |
f72ea49570d00c040562db87987674c0e7273408 | JavaScript | amargendie/MyGlobalPosition | /lib/models/WebhookInfo.js | UTF-8 | 2,616 | 2.984375 | 3 | [
"MIT"
] | permissive | 'use strict'
/**
* Contains information about the current status of a webhook.
*/
class WebhookInfo {
/**
*
* @param {string} url
* @param {boolean} hasCustomCertificate
* @param {number} pendingUpdateCount
* @param {number|null} [lastErrorDate]
* @param {string|null} [lastErrorMessage]
... | true |
f44af7aa04cf86363557c40649c2f1f780a40129 | JavaScript | CoherentLogic/ehmp20 | /ehmp/product/production/vx-sync/utils/object-utils.js | UTF-8 | 2,487 | 3.296875 | 3 | [
"Apache-2.0"
] | permissive | 'use strict';
var _ = require('underscore');
/*
Variadic Function
Functional Syntax:
getProperty(object, properties,...)
getProperty(object, properties,...)
Object Syntax:
util(object).getProperty(properties,...)
util(object).getProperty(properties,...)
This function "walks" down the list of properties given
for t... | true |
9fd77cb65b5a67bfb341a5f520e3d2245f1bf0d2 | JavaScript | jaekwangseo/FractalExercise | /app.js | UTF-8 | 4,889 | 3.25 | 3 | [] | no_license | const fs = require('fs');
let global_movies = undefined;
let movie_lookup_table = {};
/**
* Give imdb link, parses movie title id
* @param {string} link
* @return {string} movie title id
*/
const parse_imdb_id = link => {
const splitted = link.split('/');
return splitted[4];
}
/**
* Parses csv file for mov... | true |
25d012fe6f50ec3d58e28dbc9dcfef955eb1634c | JavaScript | Ravikant96/Song_app | /main.js | UTF-8 | 11,335 | 2.96875 | 3 | [
"MIT"
] | permissive | function toggleSong() {
var song = document.querySelector('audio');
if(song.paused == true) {
console.log('Playing');
$('.play-icon').removeClass('fa-play').addClass('fa-pause');
$('.play-icon').attr('title','Pause');
song.play();
}
else {
console.log('Pausing');
$('.play-icon').removeClass('fa-paus... | true |
49ca4e2e643c85742f6f9568e7b36b92e97b5cbd | JavaScript | bkovalevych/ark_2020_front | /src/components/chart/dataAdapter.js | UTF-8 | 1,412 | 2.59375 | 3 | [] | no_license | export default (raw_data) => {
let dataFactors = {}//{datasets: [], labels: []};
let timestamps = {};
raw_data.map(val => {
let props = {idCage: val.idCage, timestamp: val.timestamp, _id: 'data', __v: 'someData'};
Object.keys(val).map(key => {
if (props[key] !== undefined) {
... | true |
96edc865fec18befb591dcd8b8bd03a05ab327d1 | JavaScript | jiangyanna/workspace | /node/stream.js | UTF-8 | 2,370 | 3.625 | 4 | [] | no_license | /**
* stream:Nodejs提供的仅在服务器端可用的模块,目的是支持“流”这种数据结构。
* 流是一种抽象的数据结构,比如敲键盘时可以把每个字符依次连起来,看成字符流。
* 从键盘上输入到应用程序的流,是标准输入流(stdin);应用程序把字符输出到显示器上,是标准输出流(stdout)
* Node.js中,流是一个对象,可以响应流的事件:data事件表示流已经可以读取了;end事件表示流已经到末尾了,没有数据
* 可以读取了;err事件表示出错了
*/
'use strict'
var fs = require("fs");
/**
* 所有可以读取数据的流都继承自stream.Readable,... | true |
7b26c3c547c042016f483c4583dc4ef594f240de | JavaScript | davidbouchard/ica-2021 | /week-6/ica-parameters/sketch.js | UTF-8 | 1,313 | 3.71875 | 4 | [] | no_license | // ------------------------------------------------------------------
// Code placed in setup() will run once at the beginning
function setup() {
// Create a new canvas to match the browser size
createCanvas(windowWidth, windowHeight);
}
// ------------------------------------------------------------------
// On w... | true |
4a51273ca9017fb6dc73a88ad4d15abc10abe274 | JavaScript | ynonp/mobileweb-examples | /ajax/Handlebars/Demo2/render.js | UTF-8 | 878 | 3.015625 | 3 | [] | no_license | (function() {
var render = function() {
var source = document.getElementById('tmpl-entry').innerHTML;
var template = Handlebars.compile(source);
var context = {
name: 'Jimmy Jones',
pets: ['dog', 'cat', 'penguin']
};
Handlebars.... | true |
2a03599fb1812f6b1d24f45cdf133e13ba45b8e8 | JavaScript | lilugirl/data-wrangling-with-javascript | /chapter-3/3.9/toolkit/file.js | UTF-8 | 307 | 2.546875 | 3 | [
"MIT"
] | permissive | const fs = require("fs");
function read(fileName) {
return new Promise((resolve, reject) => {
fs.readFile(fileName, "utf-8", function (err, textFileData) {
if (err) {
reject(err);
return;
}
resolve(textFileData);
});
});
}
module.exports = {
read: read,
}; | true |
1392658b46c2fa6203cce421d64dc5bc5c7d6296 | JavaScript | trizisbea/serratec-logica-programacao | /FaseSeis/Jessica.js | UTF-8 | 429 | 3.328125 | 3 | [] | no_license | const prompt = require("prompt-sync")();
var sapato = [];
sapato[0] = "Sandalia";
sapato[1] = "Bota";
sapato[2] = "Rasteirinha";
sapato[3] = "Tenis azul";
sapato[4] = "Scarpin";
sapato[5] = "Pantufa";
var numero = prompt("Qual o número da gaveta para guardar? ");
var calcado = prompt("Qual sapato você quer guardar? ... | true |
802842329da175de74784ce3c3b88cb40e38c4c5 | JavaScript | ramanasha/FlashCards | /reducers/index.js | UTF-8 | 1,136 | 2.609375 | 3 | [] | no_license | import {
ADD_QUIZ,
ADD_QUIZZES,
ADD_QUESTION,
DELETE_QUIZ,
DELETE_QUESTION,
} from '../actions'
function quizzes (state ={}, action) {
const { key, quizData, quizzes, question } = action
switch(action.type) {
case ADD_QUIZZES:
return {
...state,
...quizzes,
}
case... | true |
b667dfaec2bc0c34bf7bd7a88a6e549ed6851ab0 | JavaScript | jfahrenkrug/cappuccino.org | /controllers/downloads.js | UTF-8 | 2,198 | 2.609375 | 3 | [] | no_license |
var File = require("file");
var downloadsPath = "public/downloads";
var getAvailableCappuccinoDownloads = function()
{
var matchingDownloads = File.path(downloadsPath).glob("CappuccinoStarter-*.zip"),
availableDownloads = [];
matchingDownloads.forEach(function(d)
{
var version = d.substr... | true |
01a15b011a568cd595c89ff736779ab122a1d8d8 | JavaScript | dougrchamberlain/oregon-trail | /main-menu.js | UTF-8 | 2,074 | 2.78125 | 3 | [] | no_license |
import Blessed from 'blessed';
import game from './game';
let interval;
function mainMenuModule(screen){
const commands = {
1() {
process.emit('player:continue');
},
'q'() {
clearInterval(interval);
const exitQuestion = Blessed.question({
... | true |
6897a6a5a9879980b712f1cc71c22f9a3b88bc9a | JavaScript | seragelgamal/delete-arrays-concept-exercises | /main.js | UTF-8 | 463 | 3.71875 | 4 | [] | no_license | // q1
// a
// array1.pop();
// b
// array1.shift();
// c
// array1.splice(4, 1);
// q2
function removeLongNames(names) {
for (let i = 0; i < names.length; i++) {
if (names[i].length > 4) {
names.splice(i, 1);
i--;
}
}
}
// q3
function removeAll(anArray, item) {
fo... | true |
5b06905eaa36ad2af3532bab487932e2ad920383 | JavaScript | Perrishnikov/covidBrown | /scripts/index.js | UTF-8 | 13,461 | 2.609375 | 3 | [] | no_license | /* global */
// import { html, render } from 'https://unpkg.com/lit-html?module'; //PROD
// import { html, render } from '../node_modules/lit-html/lit-html.js'; //DEV
import { storageAvailable, getWithExpiry, setWithExpiry, fetchData, isMobile } from './general.js';
import { parseData, validateFeatures, getUrl, getTop... | true |
06717535218b934408f61273a3645bdfb851beb7 | JavaScript | robertvari/StylusShop | /stylus_gui/src/components/shop/ItemCard.js | UTF-8 | 2,322 | 2.625 | 3 | [] | no_license | import React, {useContext, useState, useEffect, Fragment} from 'react';
import {Intcomma} from "../../utilities";
import {ShoppingCartContext} from "../contexts/ShoppingCart";
function ItemCard(props) {
const {title, card_image, price, discount_price, in_stock, short_description, id} = props.data
const {shopp... | true |
cc7c9d75e30c4ddeb533923c3dd6b6c37ab03a40 | JavaScript | AleshaD/snake | /js/services/snakeService.js | UTF-8 | 5,208 | 2.765625 | 3 | [] | no_license | /**
* Created by a on 07.09.16.
*/
snakeApp.factory ('snakeService', function (){
return {
snake: {
parts: [],
_startCreate: function () {
this.parts.push({id: 0, x: 81, y: 153});
for (var i=1; i<4; i++){
this.parts.push({id: i,... | true |
e2fe4b8a2cdda2044d137ba27c91a1273813b427 | JavaScript | albertvazquezm/startingtogether-javascript-I | /2-datatypes.js | UTF-8 | 987 | 4.40625 | 4 | [] | no_license | /**
* Hay 8 tipos de datos en JavaScript
*
* - PRIMITIVOS
*
* - string: cadenas de texto
* - number: numeros hasta ±2^53 (Sólo si vamos a operar con ellos)
* - boolean: for true/false.
*
* - null: "sin valor"
* - undefined: "sin asignar"
*
* - bigint: numeros de cualquier longitud
* - symbol: valor único e... | true |
2d4d50913209582720ee0e98ea2ddc82221c2320 | JavaScript | Hakerh400/web | /projects/circles/main.js | UTF-8 | 1,841 | 2.71875 | 3 | [
"Unlicense"
] | permissive | 'use strict';
const {pi2} = O;
const radius = 60;
const {g} = O.ceCanvas();
const {canvas} = g;
let iw, ih, iwh, ihh;
let cx, cy;
const main = () => {
O.ael('resize', onResize);
onResize();
cx = iwh;
cy = ihh;
O.ael('mousemove', evt => {
cx = evt.clientX;
cy = evt.clientY;
... | true |
694faedf9e9987b28599059982740a8d9594a181 | JavaScript | Jaco26/pet-hotel | /server/routes/petRouter.js | UTF-8 | 4,630 | 2.625 | 3 | [] | no_license | const express = require('express');
const router = express.Router();
const pool = require('../modules/pool.js');
router.post('/', function(req, res) {
const addedOwner = req.body;
const sqlText = `INSERT INTO owners (first_name, last_name)
VALUES ($1, $2);`;
pool.query(sqlText, [addedOwner.first_name, ... | true |
6521c89bbe46e2c0daaff4ccf54055e737a0e16f | JavaScript | sebagabs/software-product-sprint | /portfolio/src/main/webapp/script.js | UTF-8 | 1,950 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | true |
682ef9172262d313830368358749799cea31421b | JavaScript | robomantis19/react-american-football-scoreboard | /src/App.js | UTF-8 | 3,000 | 3.203125 | 3 | [] | no_license | //TODO: STEP 1 - Import the useState hook.
import React, { useState, useEffect } from "react";
import "./App.css";
import BottomRow from "./BottomRow";
import { tsPropertySignature } from "@babel/types";
function App() {
//TODO: STEP 2 - Establish your applictaion's state with some useState hooks. You'll need one f... | true |
c8d8b5bbf5926059158ea75ef1a5d5d0fd9268fa | JavaScript | sahibamj/Password-Generator | /script.js | UTF-8 | 2,153 | 3.703125 | 4 | [] | no_license | // Assignment Code
var generateBtn = document.querySelector("#generate");
function generatePassword() {
var numbers = "1234567890";
var symbols = "~!@#$%^&*(){}"
var uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var lowercase = "abcdefghijklmnopqrstuvwxyz";
var passwordlength = "";
var lowerConfirm;
var upperCo... | true |
ae1451d8a4dae3af637d097aac0dc97c2cb032a4 | JavaScript | adeadebimpe/todolist | /script.js | UTF-8 | 1,522 | 3.328125 | 3 | [] | no_license | var myList = document.getElementsByTagName("li");
var i;
for (i = 0; i < myList.length; i++){
var span = document.createElement("span");
var txt = document.createTextNode("\u00D7");
span.className = "close";
span.appendChild(txt);
myList[i].appendChild(span);
}
//on click close
var close... | true |
7bf8ca9c5f66d19ac516628f66814d70b4d777c3 | JavaScript | Shadowcyng/todo-list | /src/App.js | UTF-8 | 933 | 2.578125 | 3 | [] | no_license | import React, { useState, useEffect } from 'react'
import Todo from './Components/Todo'
import './App.css'
import db from './Components/firebase'
import 'tachyons'
import Scroll from './Components/Scroll'
import Form from './Components/Form'
function App() {
const [todos,setTodos] = useState([])
//When the app lo... | true |
13c22b30a44fe56c520535d3326500715adf572d | JavaScript | scolsen/nshell-das | /lib/core/helprender.js | UTF-8 | 1,040 | 2.640625 | 3 | [] | no_license | /**
* Created by scolsen on 2/7/17.
* helper function for rendering process helps.
*/
const fs = require('fs');
function renderhelp(inputfile, output){
console.log(shellRoot);
console.log(inputfile);
if (inputfile.match(/.*help\.json/) == null) {
inputfile = inputfile + '/help.json'
... | true |
474b8036d8588902f379362761165a64a99db2d7 | JavaScript | joshbailey98/CST-356-Labs | /Week 4/src/js/students.js | UTF-8 | 672 | 3.265625 | 3 | [] | no_license | var testStudents = '{"students": [{"id": "asdf", "email": "asdf@gmail.com"}, {"id": "qwer", "email": "qwer@gmail.com"}, {"id": "zxcv", "email": "zxcv@gmail.com"}, {"id": "cvbn", "email": "cvbn@gmail.com"}, {"id": "dfgh", "email": "dfgh@gmail.com"}]}';
function getStudents() {
return JSON.parse(testStudents);
}
fu... | true |
b59cbbe3d9dcd99fce003b778e3c21f3afe5a6ec | JavaScript | JamesMonroe504/JamesMonroe504.github.io | /studies/control-flow.js | UTF-8 | 3,596 | 4.53125 | 5 | [] | no_license | /* 0. Control Flow controls the flow of the program.
* We make decisions in our code based on asking true and false questions
* If the first answer isn't true it will continue to the next one until it has an answer that is true or it will print a default value
*
* Use if to specify a block of code to be execu... | true |
a1e9978bae3e982db3f3b5897b5344dac28d743c | JavaScript | aautar/display-toggle-fx | /test/DisplayToggleFx.test.js | UTF-8 | 4,733 | 2.6875 | 3 | [
"MIT"
] | permissive | /**
* @jest-environment jsdom
*/
const $ = require('jquery');
const DisplayToggleFx = require('../src/DisplayToggleFx.js');
test('DisplayToggleFx.in adds classes to element', () => {
$('body').html(`<div id="telem" style="display:none; transition: opacity 0.3s ease-in, transform 0.9s linear;"></div>`);
... | true |
17d9930986b02fb8ab0f104a85805e534b95fde5 | JavaScript | dongzigang/code | /test/ES6-async.js | UTF-8 | 2,917 | 4.25 | 4 | [
"Apache-2.0"
] | permissive | //es6 三种异步方案对比
/**
* promise
* 优点:解决了回调地狱
* 缺点:
* 1.无法取消Promise,一旦新建它就会立即执行,无法中途取消。
* 2.如果不设置回调函数,Promise内部抛出的错误,不会反应到外部。
* 3.当处于pending状态时,无法得知目前进展到哪一个阶段(刚刚开始还是即将完成)
*
*
* promise方法体内的代码为同步,then()里的代码异步
* */
function promiseDemo() {
return new Promise((resolve, reject)=>{
setTimeout(()=>{
resolv... | true |
10bf2e9add7fea32bdc368da0c86541e5a9b4707 | JavaScript | caldwelljt2/fcc_tests | /missingLetters.js | UTF-8 | 891 | 4 | 4 | [] | no_license | function fearNotLetter(str) {
let alphabet = "abcdefghijklmnopqrstuvwxyz"
let firstLetter = alphabet.indexOf(str[0])
for (let i = firstLetter; i < firstLetter + str.length; i++)
{
if (str[i-firstLetter] != alphabet[i]) {
return alphabet[i]
}
}
return undefined;
... | true |
9e6b66bfd6b24d075301c2a2fa4c1ca44af67be7 | JavaScript | eusousalvi/simple-node-backend | /src/middlewares/auth.js | UTF-8 | 674 | 2.53125 | 3 | [] | no_license | const jwt = require('jsonwebtoken');
module.exports = (req, res, next) => {
const authHeader = req.headers.authorization;
if (!authHeader) return res.status(401).send({ error: 'O token não foi fornecido' });
const parts = authHeader.split(' ');
if (!parts.length === 2) return res.status(401).send({ error: '... | true |
4faaed285803d4540c9c0ae0670aea58cf285067 | JavaScript | Louis-C-Leon/Soundcloud-FSP | /frontend/util/song_util.jsx | UTF-8 | 684 | 2.5625 | 3 | [] | no_license | export const fetchSongs = () => {
return $.ajax({
url: "api/songs",
method: "get"
})
}
export const fetchSong = (id) => {
return $.ajax({
url: `api/songs/${id}`
})
}
export const createSong = (song) => {
return $.ajax({
url: "api/songs",
method: "post",
data: song,
processData: f... | true |
666786cd3b105eab7cdd856297ce2c73997152c7 | JavaScript | blinded93/react-forms-v-000 | /src/components/ControlledInput.js | UTF-8 | 1,045 | 2.65625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | import React, { Component } from 'react'
export default class ControlledInput extends Component {
state = {
firstName:"Kyle",
lastName:"Hughes"
}
handleChange = event => {
this.setState({
[event.target.name]: event.target.value
})
}
render() {
r... | true |
9da3bff55ab85456fcbb95ad100a58f5e2c9395f | JavaScript | EvanGuoNTUB/alphacamp | /Restaurant_List_NodeJS/app.js | UTF-8 | 1,388 | 2.90625 | 3 | [] | no_license | // initialize basic functions
const express = require('express')
const app = express()
const handlebars = require('express-handlebars')
const restaurantList = require('./restaurant.json')
const port = 3000
// template engine setting
app.engine('handlebars', handlebars({ defaultLayout: 'main' }))
app.set('view engine',... | true |
1d4146821830b69d390f3f293b2db368d48a7d04 | JavaScript | jawwadakhter674/news_website | /app.js | UTF-8 | 2,559 | 3.234375 | 3 | [] | no_license | // 16a4159429954d79be3467188ca26058
// https://newsapi.org/v2/everything?q=tesla&from=2021-07-10&sortBy=publishedAt&apiKey=16a4159429954d79be3467188ca26058
var computer=document.getElementById('computer')
var mobile=document.getElementById('mobile')
var weather=document.getElementById('weather')
var cricket=document.... | true |