├── chapter16 ├── test.txt ├── process.js ├── file_util.js ├── hello_world.js ├── lib.js ├── use_lib.js ├── .gitignore ├── child_process.js ├── child.js ├── pie.js ├── spawn.js ├── hello.js ├── fork.js ├── stream.js ├── fetch.js ├── clone.js ├── AsyncRead.js ├── server.js ├── os.js ├── ReadSync.js ├── exec.js ├── event.js ├── fetch_data.js ├── hello.ts ├── process_api.js ├── buffer.js └── path.js ├── backend ├── data.txt ├── .idea │ ├── .gitignore │ ├── misc.xml │ ├── vcs.xml │ ├── modules.xml │ └── backend.iml ├── .DS_Store ├── config │ ├── database.js │ └── Config.js ├── views │ ├── index.jade │ ├── error.jade │ └── layout.jade ├── public │ └── stylesheets │ │ └── style.css ├── controller │ └── User.js ├── model │ ├── user.js │ ├── Review.js │ └── Movie.js ├── routes │ ├── movies.js │ └── reviews.js ├── package.json └── swagger.json ├── chapter13 ├── hello.txt ├── another.txt ├── SyncRead.js ├── ReadFilePromise.js ├── FileRead.js ├── FetchDemo.html ├── PromiseChain.html ├── PromiseAsErrorHandling.html ├── ForAwait.html ├── Await.html ├── Event.html └── Promise.html ├── chapter15 ├── async.js ├── defer.js ├── animation.js ├── lib.js ├── worker.js ├── DomDemo.html ├── Global.html ├── PreSelected.html ├── fworker.js ├── LocalStorage.html ├── SessionStorage.html ├── Worker.html ├── LocalStorage2.html ├── ClosureLeak.html ├── DeattachedDOMLeak.html ├── Animation.html └── ElementContent.html ├── chapter5 ├── tempCodeRunnerFile.go ├── go_to_demo.go ├── ForIn.html ├── With.html ├── While.html ├── Statement.html ├── Declaration.html ├── Frequency.html ├── LabelledLoop.html ├── Yield.html ├── UseStrict.html ├── Break.html ├── Return.html ├── NestedArray.html ├── IfStatement.html ├── Conditional.html └── Finally.html ├── hello_word.js ├── .DS_Store ├── chapter10 ├── use_module.js ├── es6.js ├── my_module.js ├── UseModule.html └── IIFE_Module.html ├── StaticType ├── fp ├── .DS_Store ├── pipe.fsx ├── compose.fsx ├── curry.fsx ├── Times.html ├── Abstraction.html ├── HOF.html ├── Flatten.html ├── MayBeProblem.html ├── Monoid.html ├── curry_with_ramda.html ├── Once.html ├── CustomCompose.html ├── Unary.html ├── Functor.html ├── Zip.html ├── MonadProblem.html ├── memonize.html ├── Predicate.html ├── Monad.html └── GroupBy.html ├── react-redux-fourth-batch ├── src │ ├── setting │ │ ├── API.js │ │ └── our_axios.js │ ├── pages │ │ ├── HomePage.js │ │ └── LogoutPage.js │ ├── util │ │ └── Util.js │ ├── features │ │ ├── reviews │ │ │ ├── Reivew.js │ │ │ └── reviewApi.js │ │ ├── counter │ │ │ └── counterAPI.js │ │ ├── auth │ │ │ └── authApi.js │ │ ├── movies │ │ │ ├── Movie.css │ │ │ ├── MovieList.js │ │ │ └── movieApi.js │ │ └── todos │ │ │ ├── todoAPI.js │ │ │ └── ToDoCount.js │ ├── app │ │ ├── hooks.js │ │ └── store.js │ ├── setupTests.js │ ├── index.css │ ├── reportWebVitals.js │ ├── App.test.js │ ├── services │ │ └── authService.js │ ├── routes │ │ └── ProtectedRoute.js │ └── App.css ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ └── manifest.json ├── .idea │ ├── .gitignore │ ├── vcs.xml │ ├── inspectionProfiles │ │ └── Project_Default.xml │ ├── modules.xml │ └── react-redux-fourth-batch.iml └── .gitignore ├── redux-typescript-fourth-batch ├── src │ ├── react-app-env.d.ts │ ├── setting │ │ └── API.ts │ ├── pages │ │ ├── HomePage.tsx │ │ ├── LogoutPage.tsx │ │ └── MoviePage.tsx │ ├── features │ │ ├── counter │ │ │ └── counterAPI.ts │ │ ├── movies │ │ │ ├── Movie.css │ │ │ ├── MovieListUI.tsx │ │ │ └── movieApi.ts │ │ ├── auth │ │ │ └── authApi.ts │ │ └── todo │ │ │ └── todoApi.ts │ ├── setupTests.ts │ ├── app │ │ └── hooks.ts │ ├── index.css │ ├── services │ │ └── authService.ts │ ├── App.test.tsx │ ├── reportWebVitals.ts │ ├── component │ │ └── PrivateRoute.tsx │ └── App.css ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ └── manifest.json ├── .idea │ ├── .gitignore │ ├── vcs.xml │ ├── inspectionProfiles │ │ └── Project_Default.xml │ ├── modules.xml │ └── redux-typescript-fourth-batch.iml ├── .gitignore └── tsconfig.json ├── typescript ├── date_const.js ├── .DS_Store ├── unknown.ts ├── type_extend.js ├── compatiable.js ├── compatiable.ts ├── function_type_2.ts ├── interface_extend.js ├── function_type_2.js ├── definitely_assign.js ├── contract.ts ├── problem.js ├── infer_this.ts ├── structural_typing.js ├── union.js ├── infer_this.js ├── overload.js ├── rest.ts ├── date_const.ts ├── interface.js ├── definitely_assign.ts ├── gen_fun.js ├── function_type.js ├── hello.js ├── array.js ├── function.js ├── hello.ts ├── alias.js ├── type_extend.ts ├── interface_extend.ts ├── array.ts ├── assign.js ├── anno.js ├── call_sing.js ├── function.ts ├── interface.ts ├── union.ts ├── runtime_this.ts ├── init.ts ├── composite.js ├── null.js ├── overload.ts ├── unition_2.ts ├── constraint.js ├── construct_sing.js ├── null.ts ├── rest.js ├── anno.ts ├── constraint.ts ├── function_type.ts ├── unition_2.js ├── assign.ts ├── alias.ts ├── generic.ts ├── call_sing.ts ├── super.ts ├── construct_sing.ts ├── runtime_this.js ├── structural_typing.ts ├── gen_fun.ts ├── arrow.ts ├── generic.js ├── composite.ts ├── static.ts ├── arrow.js └── static.js ├── chapter11 ├── WeakMapSet.html ├── StringCompare.html ├── Garbage.html ├── Url.html ├── Intl.html ├── RegEmail.html ├── TypeArray.html ├── ConsoleError.html ├── Endian.html ├── Timer.html ├── Reg7.html ├── Reg5.html ├── ThreadDemo.java ├── JsonParse.html └── JSON.html ├── react-frontend ├── public │ ├── robots.txt │ ├── cat.jpg │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ └── manifest.json ├── src │ ├── components │ │ ├── FancyBorder.css │ │ ├── function_component │ │ │ ├── Hello.js │ │ │ ├── hook │ │ │ │ ├── ContextHookDemo.js │ │ │ │ ├── UseLayoutDemo.js │ │ │ │ ├── UseRefDemo.js │ │ │ │ └── UseIdDemo.js │ │ │ └── Greeting.js │ │ ├── ToDoItem.css │ │ ├── FancyBorder.js │ │ ├── tab │ │ │ └── Tab.css │ │ ├── ListDemo.js │ │ ├── Avatar.js │ │ ├── context │ │ │ └── ThemeContext.js │ │ ├── fragment │ │ │ └── FragmentDemo.js │ │ ├── render-property │ │ │ ├── Cat.js │ │ │ └── MouseTracker.js │ │ ├── WelcomeDialog.js │ │ ├── Post.js │ │ ├── HelloWorld.js │ │ ├── jsx │ │ │ ├── RepeatDemo.js │ │ │ └── DynamicComponent.js │ │ ├── forward-ref │ │ │ └── ForwardRefDemo.js │ │ ├── error-boundary │ │ │ └── BuggyComponent.js │ │ ├── hoc │ │ │ └── logProps.js │ │ └── thrid_party │ │ │ └── DatePicker.js │ ├── OurMath.js │ ├── pages │ │ ├── About.js │ │ ├── Home.js │ │ ├── Login.js │ │ ├── MovieDetails.js │ │ ├── Users.js │ │ ├── NotFoundPage.js │ │ └── Movie.js │ ├── setupTests.js │ ├── App.test.js │ ├── index.css │ ├── routes │ │ └── ProtectedRoute.js │ ├── reportWebVitals.js │ └── App.css ├── .idea │ ├── .gitignore │ ├── vcs.xml │ ├── inspectionProfiles │ │ └── Project_Default.xml │ ├── modules.xml │ └── react-frontend.iml └── .gitignore ├── hello.js ├── chapter3 ├── exchange.py ├── DateTime.html ├── Untype.html ├── FloatingProblem.html ├── VariableDeclaration.html ├── Equality.html ├── Global.html ├── Boolean.html ├── ObjectDest.html ├── Destructuring.html ├── Arithmetic.html ├── Number.html ├── ObjectToPrimitive.html ├── Zero.html ├── NullUndefined.html └── Mutable.html ├── hello.ts ├── chapter2 ├── ASI.html ├── LexicalStructure.html ├── Identifier.html └── Literal.html ├── chapter6 ├── Assign.html ├── custom_loop.rb ├── Problem.html ├── Acces.html ├── ShorthandMethod.html ├── Spread.html ├── Literal.html ├── Extend.html ├── Mapping.html ├── Create.html ├── GetterSetter.html ├── Validation.html ├── ExtendLiteral.html ├── Seralization.html ├── Logger.html ├── Encapsulation.html └── Object.html ├── chapter8 ├── FunctionConstructor.html ├── Problem2.html ├── Destructuring.html ├── Arrorw.html ├── MultipleReturn.html ├── ObjectDestructuring.html ├── IIFE.html ├── Property.html ├── Namespace.html ├── RestParameter.html ├── multi_return.go ├── StackClousre.html ├── ArgumentPar.html ├── Optional.html ├── FunctionExpression.html ├── Bind.html ├── ClosureProblem.html ├── FunctionCall.html ├── Function.html ├── Scope.html ├── NestedFunc.html ├── OtherMethod.html ├── Closure.html ├── ParameterPass.html ├── FunctionProperty.html ├── Value.html └── CallApply.html ├── chapter4 ├── Conditional.html ├── Precedence.html ├── Unary.html ├── PropertyAccess.html ├── Operator.html ├── Comparison.html ├── Default.html ├── In.html ├── Not.html ├── Expression.html ├── Bitwise.html └── Assignment.html ├── chapter7 ├── SpareArray.html ├── AddDelete.html ├── Queue.html ├── CopyWithin.html ├── StringAsArray.html ├── UndefinedEmpty.html ├── Concat.html ├── Flat.html ├── IndexOf.html ├── ReadWrite.html ├── ArrToString.html ├── Slice.html ├── MultiDimensionalArray.html ├── Reduce.html └── Filter.html ├── Comment.html ├── StaticType.cpp ├── Dynamic.html ├── chapter14 ├── Template.html ├── Extensibility.html └── Prototype.html ├── Pragmatic.html └── chapter9 ├── DuckTyping.html ├── Private.html ├── StaticType.java ├── ClassExpression.html ├── Class2.html ├── Class.html └── Generator.html /chapter16/test.txt: -------------------------------------------------------------------------------- 1 | Hello -------------------------------------------------------------------------------- /backend/data.txt: -------------------------------------------------------------------------------- 1 | Downloaded file -------------------------------------------------------------------------------- /chapter13/hello.txt: -------------------------------------------------------------------------------- 1 | another.txt -------------------------------------------------------------------------------- /chapter13/another.txt: -------------------------------------------------------------------------------- 1 | This is final content -------------------------------------------------------------------------------- /chapter15/async.js: -------------------------------------------------------------------------------- 1 | console.log("Async called"); -------------------------------------------------------------------------------- /chapter15/defer.js: -------------------------------------------------------------------------------- 1 | console.log("Defer called"); -------------------------------------------------------------------------------- /chapter5/tempCodeRunnerFile.go: -------------------------------------------------------------------------------- 1 | fmt.Println("End") -------------------------------------------------------------------------------- /hello_word.js: -------------------------------------------------------------------------------- 1 | console.log("Hello World form Node.js"); -------------------------------------------------------------------------------- /chapter16/process.js: -------------------------------------------------------------------------------- 1 | console.log("Process argv ",process.argv); -------------------------------------------------------------------------------- /backend/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /workspace.xml 3 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/.DS_Store -------------------------------------------------------------------------------- /chapter10/use_module.js: -------------------------------------------------------------------------------- 1 | const myModule = require('./my_module'); 2 | myModule.hello(); -------------------------------------------------------------------------------- /StaticType: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/StaticType -------------------------------------------------------------------------------- /fp/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/fp/.DS_Store -------------------------------------------------------------------------------- /chapter10/es6.js: -------------------------------------------------------------------------------- 1 | export function show() 2 | { 3 | console.log("Show from Module"); 4 | } 5 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/setting/API.js: -------------------------------------------------------------------------------- 1 | export const API_URL = "http://localhost:3000/api/"; -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /backend/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/backend/.DS_Store -------------------------------------------------------------------------------- /chapter16/file_util.js: -------------------------------------------------------------------------------- 1 | console.log("Current Path ",__filename); 2 | console.log("Dir Path ",__dirname); -------------------------------------------------------------------------------- /chapter16/hello_world.js: -------------------------------------------------------------------------------- 1 | console.log("Hello World from Node.js"); 2 | //console.log("Window ",document); -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/setting/API.ts: -------------------------------------------------------------------------------- 1 | export const API_URL = "http://localhost:3000/api"; -------------------------------------------------------------------------------- /backend/config/database.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | db: 'mongodb://0.0.0.0:27017/react_fourth_batch' 3 | } -------------------------------------------------------------------------------- /react-redux-fourth-batch/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | -------------------------------------------------------------------------------- /typescript/date_const.js: -------------------------------------------------------------------------------- 1 | function fn(ctor) { 2 | console.log("Ctor ", ctor); 3 | } 4 | fn(Date); 5 | -------------------------------------------------------------------------------- /backend/views/index.jade: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h1= title 5 | p Welcome to #{title} 6 | -------------------------------------------------------------------------------- /chapter11/WeakMapSet.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /react-frontend/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /react-frontend/src/components/FancyBorder.css: -------------------------------------------------------------------------------- 1 | .fancy-border 2 | { 3 | border: 1px solid darkgoldenrod; 4 | } -------------------------------------------------------------------------------- /typescript/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/typescript/.DS_Store -------------------------------------------------------------------------------- /hello.js: -------------------------------------------------------------------------------- 1 | var a = "Hello"; 2 | console.log('Type of', typeof a); 3 | a = 20; 4 | console.log('Type of', typeof a); 5 | -------------------------------------------------------------------------------- /typescript/unknown.ts: -------------------------------------------------------------------------------- 1 | function f1(a: any) { 2 | a.b(); // OK 3 | } 4 | function f2(a: unknown) { 5 | a.b(); 6 | } -------------------------------------------------------------------------------- /chapter3/exchange.py: -------------------------------------------------------------------------------- 1 | a = 10 2 | b = 20 3 | #temp = b 4 | #b = a 5 | #a = temp 6 | b , a = a , b 7 | print("a ",a, " B ",b) -------------------------------------------------------------------------------- /hello.ts: -------------------------------------------------------------------------------- 1 | var a = "Hello"; 2 | console.log('Type of', typeof a); 3 | 4 | //a = 20; 5 | console.log('Type of', typeof a); -------------------------------------------------------------------------------- /fp/pipe.fsx: -------------------------------------------------------------------------------- 1 | let double x = x* 2; 2 | let tripple x = x * 3; 3 | let data = 2 |> double |>tripple; 4 | printfn "Data is %d " data -------------------------------------------------------------------------------- /react-frontend/public/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/react-frontend/public/cat.jpg -------------------------------------------------------------------------------- /react-frontend/src/OurMath.js: -------------------------------------------------------------------------------- 1 | export function add(a,b) 2 | { 3 | console.log('Add ',a, " ",b); 4 | return a + b; 5 | } -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /typescript/type_extend.js: -------------------------------------------------------------------------------- 1 | var bear = { 2 | name: 'Bear Name', 3 | honey: true 4 | }; 5 | console.log('Bear ', bear); 6 | -------------------------------------------------------------------------------- /backend/views/error.jade: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h1= message 5 | h2= error.status 6 | pre #{error.stack} 7 | -------------------------------------------------------------------------------- /chapter16/lib.js: -------------------------------------------------------------------------------- 1 | console.log("Module initalized"); 2 | const add =(x,y)=> 3 | { 4 | return x+y; 5 | }; 6 | exports.add = add; -------------------------------------------------------------------------------- /chapter16/use_lib.js: -------------------------------------------------------------------------------- 1 | const lib = require('./lib.js'); 2 | const lib2 = require('./lib.js'); 3 | 4 | console.log("Add ",lib.add(1,2)); -------------------------------------------------------------------------------- /fp/compose.fsx: -------------------------------------------------------------------------------- 1 | let plusTwo x = x + 2; 2 | let tripple x = x * 3; 3 | let func = plusTwo >> tripple; 4 | printfn "Data is %d " (func 2) -------------------------------------------------------------------------------- /typescript/compatiable.js: -------------------------------------------------------------------------------- 1 | var k; 2 | k = "Hello"; 3 | var str = 30; 4 | //k = str; 5 | str = k; 6 | console.log("str ", str); 7 | -------------------------------------------------------------------------------- /react-frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/react-frontend/public/favicon.ico -------------------------------------------------------------------------------- /react-frontend/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/react-frontend/public/logo192.png -------------------------------------------------------------------------------- /react-frontend/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/react-frontend/public/logo512.png -------------------------------------------------------------------------------- /react-frontend/src/pages/About.js: -------------------------------------------------------------------------------- 1 | export default function About(props) 2 | { 3 | return (
4 | About 5 |
) 6 | } -------------------------------------------------------------------------------- /react-frontend/src/pages/Home.js: -------------------------------------------------------------------------------- 1 | export default function Home(props) 2 | { 3 | return (
4 | Home 5 |
); 6 | } -------------------------------------------------------------------------------- /react-frontend/src/pages/Login.js: -------------------------------------------------------------------------------- 1 | export default function Login(props) 2 | { 3 | return
4 | Login 5 |
6 | } -------------------------------------------------------------------------------- /typescript/compatiable.ts: -------------------------------------------------------------------------------- 1 | let k ; 2 | k = "Hello"; 3 | let str :number = 30; 4 | //k = str; 5 | 6 | str = k; 7 | console.log("str ",str); -------------------------------------------------------------------------------- /typescript/function_type_2.ts: -------------------------------------------------------------------------------- 1 | function doSomething(f: Function) { 2 | return f(1, 2, 3); 3 | } 4 | doSomething(()=>console.log('Hello')); -------------------------------------------------------------------------------- /typescript/interface_extend.js: -------------------------------------------------------------------------------- 1 | var bear = { 2 | name: 'Bear Name', 3 | honey: 'honey' 4 | }; 5 | console.log('Bear ', bear); 6 | -------------------------------------------------------------------------------- /fp/curry.fsx: -------------------------------------------------------------------------------- 1 | let add x y = x + y 2 | let add2 = add 2 3 | printfn "Result %A " add2 4 | 5 | let result = add2 4 6 | printfn "Result %A" result 7 | -------------------------------------------------------------------------------- /backend/config/Config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | config:{ 3 | TOKEN_SECRET : "!&#^&!^#!722!@@(!" //should be store in env file, 4 | } 5 | } -------------------------------------------------------------------------------- /chapter15/animation.js: -------------------------------------------------------------------------------- 1 | console.log("Animation loaded"); 2 | setInterval(()=>{ 3 | document.getElementById("time").innerText = new Date(); 4 | },1000); -------------------------------------------------------------------------------- /react-frontend/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | -------------------------------------------------------------------------------- /chapter15/lib.js: -------------------------------------------------------------------------------- 1 | console.log("Lib Dynamically loaded"); 2 | 3 | function hello() 4 | { 5 | console.log('Hello invoked'); 6 | console.log(data); 7 | } -------------------------------------------------------------------------------- /react-redux-fourth-batch/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/react-redux-fourth-batch/public/favicon.ico -------------------------------------------------------------------------------- /react-redux-fourth-batch/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/react-redux-fourth-batch/public/logo192.png -------------------------------------------------------------------------------- /react-redux-fourth-batch/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/react-redux-fourth-batch/public/logo512.png -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/pages/HomePage.js: -------------------------------------------------------------------------------- 1 | export default function HomePage(props) 2 | { 3 | return (
4 | Home Page 5 |
) 6 | } -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/pages/HomePage.tsx: -------------------------------------------------------------------------------- 1 | export default function HomePage() 2 | { 3 | return (
4 | Home Page 5 |
) 6 | } -------------------------------------------------------------------------------- /typescript/function_type_2.js: -------------------------------------------------------------------------------- 1 | function doSomething(f) { 2 | return f(1, 2, 3); 3 | } 4 | doSomething(function () { return console.log('Hello'); }); 5 | -------------------------------------------------------------------------------- /chapter16/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea 3 | .tscache 4 | .DS_Store 5 | node_modules/ 6 | typings/ 7 | coverage/ 8 | test/typescript/axios.js* 9 | sauce_connect.log -------------------------------------------------------------------------------- /react-redux-fourth-batch/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | -------------------------------------------------------------------------------- /typescript/definitely_assign.js: -------------------------------------------------------------------------------- 1 | var GoodGreeter = /** @class */ (function () { 2 | function GoodGreeter() { 3 | } 4 | return GoodGreeter; 5 | }()); 6 | -------------------------------------------------------------------------------- /chapter2/ASI.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /react-frontend/src/components/function_component/Hello.js: -------------------------------------------------------------------------------- 1 | export default function Hello(props) { 2 | return

Function component Hello, {props.name}

; 3 | } -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/redux-typescript-fourth-batch/public/favicon.ico -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/redux-typescript-fourth-batch/public/logo192.png -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthetkhine/TuringJSReact4thBatch/HEAD/redux-typescript-fourth-batch/public/logo512.png -------------------------------------------------------------------------------- /typescript/contract.ts: -------------------------------------------------------------------------------- 1 | interface Pingable { 2 | ping(): void; 3 | } 4 | 5 | class Sonar implements Pingable { 6 | ping() { 7 | console.log("ping!"); 8 | } 9 | } -------------------------------------------------------------------------------- /backend/views/layout.jade: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | title= title 5 | link(rel='stylesheet', href='/stylesheets/style.css') 6 | body 7 | block content 8 | -------------------------------------------------------------------------------- /chapter16/child_process.js: -------------------------------------------------------------------------------- 1 | const child_process = require("child_process"); 2 | let listing = child_process.execSync("ls -l *.js",{encoding: "utf8"}); 3 | console.log(listing); -------------------------------------------------------------------------------- /chapter3/DateTime.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /backend/public/stylesheets/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 50px; 3 | font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; 4 | } 5 | 6 | a { 7 | color: #00B7FF; 8 | } 9 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/util/Util.js: -------------------------------------------------------------------------------- 1 | export function nextId(initial) 2 | { 3 | let id = initial; 4 | return function() 5 | { 6 | return id++; 7 | } 8 | } -------------------------------------------------------------------------------- /typescript/problem.js: -------------------------------------------------------------------------------- 1 | let str = "Hello"; 2 | let result = str * 3; 3 | console.log("Result ",result); 4 | 5 | let obj = { 6 | name : "TK" 7 | }; 8 | console.log("Obj ",obj.age); -------------------------------------------------------------------------------- /chapter3/Untype.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /chapter6/Assign.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /typescript/infer_this.ts: -------------------------------------------------------------------------------- 1 | const user = { 2 | id: 123, 3 | 4 | //admin: false, 5 | becomeAdmin: function () { 6 | console.log(this.admin); 7 | }, 8 | }; 9 | user.becomeAdmin(); -------------------------------------------------------------------------------- /typescript/structural_typing.js: -------------------------------------------------------------------------------- 1 | var data = { 2 | name: "Something" 3 | }; 4 | var another = { 5 | name: "Another" 6 | }; 7 | data = another; 8 | console.log("Data ", data); 9 | -------------------------------------------------------------------------------- /typescript/union.js: -------------------------------------------------------------------------------- 1 | var s = "pending"; 2 | //s = "something"; 3 | console.log("Status ", s); 4 | var data; 5 | data = "Hello"; 6 | data = 200; 7 | console.log("Data ", data * 200); 8 | -------------------------------------------------------------------------------- /chapter8/FunctionConstructor.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /chapter10/my_module.js: -------------------------------------------------------------------------------- 1 | console.log("Module initialized"); 2 | const hello = ()=>console.log("Hello"); 3 | function display() 4 | { 5 | console.log("Display"); 6 | } 7 | exports.hello = hello; -------------------------------------------------------------------------------- /typescript/infer_this.js: -------------------------------------------------------------------------------- 1 | var user = { 2 | id: 123, 3 | //admin: false, 4 | becomeAdmin: function () { 5 | console.log(this.admin); 6 | } 7 | }; 8 | user.becomeAdmin(); 9 | -------------------------------------------------------------------------------- /chapter16/child.js: -------------------------------------------------------------------------------- 1 | process.on("message", message => { 2 | console.log("Child got message ",message); 3 | process.send({ 4 | hypotenuse: Math.hypot(message.x,message.y) 5 | }); 6 | }); -------------------------------------------------------------------------------- /chapter4/Conditional.html: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /chapter8/Problem2.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /typescript/overload.js: -------------------------------------------------------------------------------- 1 | function makeDate(m, d) { 2 | console.log("Date "); 3 | return new Date(); 4 | } 5 | var d1 = makeDate(12345678); 6 | var d2 = makeDate(5, 5); 7 | var d3 = makeDate(1, 2); 8 | -------------------------------------------------------------------------------- /typescript/rest.ts: -------------------------------------------------------------------------------- 1 | function multiply(n: number, ...m: number[]) { 2 | return m.map((x) => n * x); 3 | } 4 | // 'a' gets value [10, 20, 30, 40] 5 | const a = multiply(10, 1, 2, 3, 4); 6 | console.log('A ',a); -------------------------------------------------------------------------------- /chapter2/LexicalStructure.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /typescript/date_const.ts: -------------------------------------------------------------------------------- 1 | interface CallOrConstruct { 2 | new (s: string): Date; 3 | (n?: number): number; 4 | } 5 | function fn(ctor:DateConstructor) 6 | { 7 | console.log("Ctor ",ctor); 8 | } 9 | fn(Date); -------------------------------------------------------------------------------- /backend/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /chapter16/pie.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | 3 | function printFile(filename, encoding="utf8") 4 | { 5 | fs.createReadStream(filename,encoding) 6 | .pipe(process.stdout); 7 | } 8 | printFile('./pie.js'); -------------------------------------------------------------------------------- /typescript/interface.js: -------------------------------------------------------------------------------- 1 | function printCoord(pt) { 2 | console.log("The coordinate's x value is " + pt.x); 3 | console.log("The coordinate's y value is " + pt.y); 4 | } 5 | printCoord({ x: 100, y: 100 }); 6 | -------------------------------------------------------------------------------- /chapter10/UseModule.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /chapter15/worker.js: -------------------------------------------------------------------------------- 1 | 2 | onmessage = (event)=>{ 3 | console.log('Event in worker ',event.data); 4 | postMessage("Send back to server "+ (event.data+"").toUpperCase()); 5 | }; 6 | console.log('Worker.js loaded...'); -------------------------------------------------------------------------------- /chapter4/Precedence.html: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /chapter7/SpareArray.html: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/features/reviews/Reivew.js: -------------------------------------------------------------------------------- 1 | export default function Review({review}) 2 | { 3 | return (
4 |
{review.review}
5 |
{review.rating}
6 |
) 7 | } -------------------------------------------------------------------------------- /typescript/definitely_assign.ts: -------------------------------------------------------------------------------- 1 | class GoodGreeter { 2 | readonly name: string; 3 | 4 | constructor() { 5 | this.name = "hello"; 6 | } 7 | err() 8 | { 9 | this.name = "Change"; 10 | } 11 | } -------------------------------------------------------------------------------- /backend/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /chapter6/custom_loop.rb: -------------------------------------------------------------------------------- 1 | def custom_while(condition) 2 | loop do 3 | break unless condition.() 4 | yield 5 | end 6 | end 7 | 8 | i = 0 9 | custom_while -> { i < 5 } do 10 | puts i 11 | i += 1 12 | end -------------------------------------------------------------------------------- /chapter7/AddDelete.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /typescript/gen_fun.js: -------------------------------------------------------------------------------- 1 | function firstElement(arr) { 2 | return arr[0]; 3 | } 4 | var ele = firstElement([1, 2, 3]); 5 | console.log('Ele ', ele); 6 | var str = firstElement(["helo", "how"]); 7 | console.log('Str ', str); 8 | -------------------------------------------------------------------------------- /react-frontend/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /typescript/function_type.js: -------------------------------------------------------------------------------- 1 | var isEven = function (num) { return num % 2 == 0; }; 2 | console.log("IsEven ", isEven(30)); 3 | var something = function (fun) { 4 | return fun; 5 | }; 6 | console.log(something(isEven)(300)); 7 | -------------------------------------------------------------------------------- /chapter16/spawn.js: -------------------------------------------------------------------------------- 1 | const { spawn } = require('child_process'); 2 | 3 | const child = spawn('ls'); 4 | 5 | process.stdin.pipe(child.stdin) 6 | 7 | child.stdout.on('data', (data) => { 8 | console.log(`child stdout:\n${data}`); 9 | }); -------------------------------------------------------------------------------- /chapter7/Queue.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /typescript/hello.js: -------------------------------------------------------------------------------- 1 | var num = 5; 2 | var result = num * 3; 3 | console.log("Result ", result); 4 | var obj = { 5 | name: "TK" 6 | }; 7 | console.log("Obj ", obj.name); 8 | var str = "HelloWorld"; 9 | console.log(str); 10 | -------------------------------------------------------------------------------- /chapter8/Destructuring.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /fp/Times.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /typescript/array.js: -------------------------------------------------------------------------------- 1 | var arr = [10, 20, 30]; 2 | console.log('Arr ', arr); 3 | var anotherArray = ["one", "two", 3]; 4 | console.log('Another array ', anotherArray); 5 | var data = "str"; 6 | data = data * 3; 7 | console.log("Data ", data); 8 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /typescript/function.js: -------------------------------------------------------------------------------- 1 | function greet(msg) { 2 | console.log("Hello ", msg); 3 | } 4 | greet("Jhon"); 5 | greet("12"); 6 | function add(x, y) { 7 | return x + y; 8 | } 9 | var str = add(1, 2), something; 10 | //str = "Hello"; 11 | -------------------------------------------------------------------------------- /chapter16/hello.js: -------------------------------------------------------------------------------- 1 | var a = 10; 2 | //a = "Hello"; 3 | console.log("A ", a); 4 | var obj = { 5 | name: "TK", 6 | age: 37 7 | }; 8 | //console.log("Obj ",obj.nmae); 9 | var b = "hello"; 10 | var x = b * 1; 11 | console.log("X ", x); 12 | -------------------------------------------------------------------------------- /typescript/hello.ts: -------------------------------------------------------------------------------- 1 | let num : number = 5; 2 | let result = num * 3; 3 | console.log("Result ",result); 4 | 5 | let obj = { 6 | name : "TK" 7 | }; 8 | console.log("Obj ",obj.name); 9 | let str : string = "HelloWorld" 10 | console.log(str); -------------------------------------------------------------------------------- /chapter5/go_to_demo.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | i := 0 7 | loop: 8 | fmt.Println("hello") 9 | goto end 10 | i += 1 11 | if i < 10 { 12 | goto loop 13 | } 14 | end: 15 | fmt.Println("End") 16 | } 17 | -------------------------------------------------------------------------------- /chapter7/CopyWithin.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /chapter8/Arrorw.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /typescript/alias.js: -------------------------------------------------------------------------------- 1 | // Exactly the same as the earlier example 2 | function printCoord(pt) { 3 | console.log("The coordinate's x value is " + pt.x); 4 | console.log("The coordinate's y value is " + pt.y); 5 | } 6 | printCoord({ x: 100, y: 100 }); 7 | -------------------------------------------------------------------------------- /react-frontend/src/pages/MovieDetails.js: -------------------------------------------------------------------------------- 1 | import {useParams} from "react-router-dom"; 2 | export default function MovieDetails(props) 3 | { 4 | let params = useParams(); 5 | 6 | return (
7 | Movie Details {params.movieId} 8 |
) 9 | } -------------------------------------------------------------------------------- /typescript/type_extend.ts: -------------------------------------------------------------------------------- 1 | type Animal ={ 2 | name: string 3 | } 4 | 5 | type Bear = Animal & { 6 | honey: boolean 7 | } 8 | 9 | const bear : Bear = { 10 | name : 'Bear Name', 11 | honey :true 12 | } 13 | console.log('Bear ',bear); 14 | -------------------------------------------------------------------------------- /chapter11/StringCompare.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | -------------------------------------------------------------------------------- /chapter7/StringAsArray.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /typescript/interface_extend.ts: -------------------------------------------------------------------------------- 1 | interface Animal { 2 | name: string 3 | } 4 | 5 | interface Bear extends Animal { 6 | honey: boolean 7 | } 8 | 9 | const bear = { 10 | name : 'Bear Name', 11 | honey :'honey' 12 | } 13 | console.log('Bear ',bear); 14 | -------------------------------------------------------------------------------- /typescript/array.ts: -------------------------------------------------------------------------------- 1 | let arr : Array = [10,20,30]; 2 | console.log('Arr ',arr); 3 | 4 | let anotherArray : Array = ["one","two",3]; 5 | console.log('Another array ',anotherArray); 6 | 7 | let data : any = "str"; 8 | data = data * 3; 9 | console.log("Data ",data); -------------------------------------------------------------------------------- /typescript/assign.js: -------------------------------------------------------------------------------- 1 | var f1 = function () { 2 | return true; 3 | }; 4 | var f2 = function () { return true; }; 5 | var f3 = function () { 6 | return true; 7 | }; 8 | console.log('F1 ', f1()); 9 | console.log('F2 ', f2()); 10 | console.log('F3 ', f3()); 11 | -------------------------------------------------------------------------------- /chapter13/SyncRead.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log("Before read"); 4 | try { 5 | const data = fs.readFileSync('hello.txt', 'utf8'); 6 | console.log("File Data",data); 7 | } catch (err) { 8 | console.error(err); 9 | } 10 | console.log("After read"); -------------------------------------------------------------------------------- /chapter15/DomDemo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 | 8 | 10 | 12 | -------------------------------------------------------------------------------- /chapter15/Global.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /chapter8/MultipleReturn.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /react-frontend/src/components/ToDoItem.css: -------------------------------------------------------------------------------- 1 | .to-do-item-container 2 | { 3 | min-width: 250px; 4 | } 5 | .to-do-item 6 | { 7 | width: 200px; 8 | padding: 15px; 9 | border-radius: 10px; 10 | border: 1px solid lightgray; 11 | margin-bottom: 10px; 12 | } -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/features/counter/counterAPI.js: -------------------------------------------------------------------------------- 1 | // A mock function to mimic making an async request for data 2 | export function fetchCount(amount = 1) { 3 | return new Promise((resolve) => 4 | setTimeout(() => resolve({ data: amount }), 500) 5 | ); 6 | } 7 | -------------------------------------------------------------------------------- /typescript/anno.js: -------------------------------------------------------------------------------- 1 | var names = ["Alice", "Bob", "Eve"]; 2 | names.forEach(function (s) { 3 | console.log(s.toUpperCase()); 4 | }); 5 | function display(obj) { 6 | console.log('Obj ', obj); 7 | } 8 | display({ name: "TK", age: 38 }); 9 | display({ name: "TK" }); 10 | -------------------------------------------------------------------------------- /chapter16/fork.js: -------------------------------------------------------------------------------- 1 | const child_process = require("child_process"); 2 | 3 | let child = child_process.fork(`${__dirname}/child.js`); 4 | child.send({x: 4, y: 3}); 5 | child.on("message", message => { 6 | console.log("Parent got message ",message); 7 | child.disconnect(); 8 | }); -------------------------------------------------------------------------------- /react-frontend/src/pages/Users.js: -------------------------------------------------------------------------------- 1 | import {useSearchParams} from "react-router-dom"; 2 | 3 | export default function Users(props) 4 | { 5 | let [searchParams, setSearchParams] = useSearchParams(); 6 | return (
7 | Users {searchParams.get('name')} 8 |
) 9 | } -------------------------------------------------------------------------------- /typescript/call_sing.js: -------------------------------------------------------------------------------- 1 | function doSomething(fn) { 2 | console.log(fn.description + " returned " + fn(6)); 3 | } 4 | function isEven(num) { 5 | return num % 2 == 0; 6 | } 7 | //isEven.description = "Is even check a number is even or not"; 8 | doSomething('Hello', isEven); 9 | -------------------------------------------------------------------------------- /chapter13/ReadFilePromise.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs/promises'); 2 | fs.readFile('hello.txt', 'utf8') 3 | //.then(data=>"File read output "+data) 4 | .then(data=>fs.readFile(data,'utf-8')) 5 | .then(finalContent=> console.log('Final Content ',finalContent)) 6 | .catch(console.error); -------------------------------------------------------------------------------- /chapter16/stream.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | 3 | async function logChunks(readable) { 4 | for await (const chunk of readable) { 5 | console.log(chunk); 6 | } 7 | } 8 | 9 | const readable = fs.createReadStream('./hello.txt', {encoding: 'utf8'}); 10 | logChunks(readable); -------------------------------------------------------------------------------- /chapter4/Unary.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /react-frontend/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /chapter8/ObjectDestructuring.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /typescript/function.ts: -------------------------------------------------------------------------------- 1 | function greet(msg: string) 2 | { 3 | console.log("Hello ",msg); 4 | } 5 | greet("Jhon"); 6 | greet("12"); 7 | 8 | function add(x:number,y:number):number 9 | { 10 | return x+y; 11 | } 12 | let str = add(1,2), something:number; 13 | 14 | //str = "Hello"; -------------------------------------------------------------------------------- /typescript/interface.ts: -------------------------------------------------------------------------------- 1 | interface Point { 2 | x: number; 3 | y: number; 4 | } 5 | 6 | function printCoord(pt: Point) { 7 | console.log("The coordinate's x value is " + pt.x); 8 | console.log("The coordinate's y value is " + pt.y); 9 | } 10 | 11 | printCoord({ x: 100, y: 100 }); -------------------------------------------------------------------------------- /typescript/union.ts: -------------------------------------------------------------------------------- 1 | type promiseStatus = "pending" | "fullfilled" | "completed"; 2 | 3 | let s: promiseStatus = "pending"; 4 | //s = "something"; 5 | console.log("Status ",s); 6 | 7 | let data : number | string ; 8 | data = "Hello"; 9 | data = 200; 10 | console.log("Data ",data * 200); -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/features/counter/counterAPI.ts: -------------------------------------------------------------------------------- 1 | // A mock function to mimic making an async request for data 2 | export function fetchCount(amount = 1) { 3 | return new Promise<{ data: number }>((resolve) => 4 | setTimeout(() => resolve({ data: amount }), 500) 5 | ); 6 | } 7 | -------------------------------------------------------------------------------- /Comment.html: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /chapter3/FloatingProblem.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /react-frontend/src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /chapter16/fetch.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios'); 2 | 3 | axios 4 | .get('https://jsonplaceholder.typicode.com/todos/1') 5 | .then(res => { 6 | console.log(`statusCode: ${res.status}`); 7 | console.log(res.data); 8 | }) 9 | .catch(error => { 10 | console.error(error); 11 | }); -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/app/hooks.js: -------------------------------------------------------------------------------- 1 | import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'; 2 | 3 | // Use throughout your app instead of plain `useDispatch` and `useSelector` 4 | export const useAppDispatch = () => useDispatch(); 5 | export const useAppSelector = useSelector; 6 | -------------------------------------------------------------------------------- /typescript/runtime_this.ts: -------------------------------------------------------------------------------- 1 | class MyClass { 2 | name = "MyClass"; 3 | getName() { 4 | return this.name; 5 | } 6 | } 7 | const c = new MyClass(); 8 | const obj = { 9 | name: "obj", 10 | getName: c.getName, 11 | }; 12 | 13 | // Prints "obj", not "MyClass" 14 | console.log(obj.getName()); -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /backend/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /chapter16/clone.js: -------------------------------------------------------------------------------- 1 | let another = { 2 | value : 20 3 | } 4 | let obj = { 5 | some : another 6 | } 7 | let clone = {...obj}; 8 | clone.some.value ++; 9 | 10 | console.log("Clone.some.value ",clone.some.value); 11 | console.log("Obj.some.value ",obj.some.value); 12 | console.log("another.value ",another.value); -------------------------------------------------------------------------------- /chapter3/VariableDeclaration.html: -------------------------------------------------------------------------------- 1 | 2 | 12 | -------------------------------------------------------------------------------- /chapter5/ForIn.html: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /typescript/init.ts: -------------------------------------------------------------------------------- 1 | class Base { 2 | name = "base"; 3 | constructor() { 4 | console.log("My name is " + this.name); 5 | } 6 | } 7 | 8 | class Derived extends Base { 9 | name = "derived"; 10 | } 11 | 12 | // Prints "base", not "derived" 13 | const d = new Derived(); 14 | console.log('D.name ',d.name); -------------------------------------------------------------------------------- /react-frontend/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /react-frontend/src/pages/NotFoundPage.js: -------------------------------------------------------------------------------- 1 | import {Link} from "react-router-dom"; 2 | import React from "react"; 3 | 4 | export default function NotFoundPage(props) 5 | { 6 | return (
7 |

Not found any page-404

8 | Home   9 |
) 10 | } -------------------------------------------------------------------------------- /typescript/composite.js: -------------------------------------------------------------------------------- 1 | var tree = { 2 | children: [ 3 | { 4 | data: "1" 5 | }, 6 | { 7 | children: [ 8 | { 9 | data: "1" 10 | } 11 | ] 12 | } 13 | ] 14 | }; 15 | console.log("Tree ", tree); 16 | -------------------------------------------------------------------------------- /typescript/null.js: -------------------------------------------------------------------------------- 1 | function doSomething(x) { 2 | if (x === null) { 3 | // do nothing 4 | } 5 | else { 6 | console.log("Hello, " + x.toUpperCase()); 7 | } 8 | } 9 | doSomething("Jhon"); 10 | function liveDangerously(x) { 11 | console.log(x.toFixed()); 12 | } 13 | liveDangerously(12); 14 | -------------------------------------------------------------------------------- /backend/.idea/backend.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /react-frontend/src/components/FancyBorder.js: -------------------------------------------------------------------------------- 1 | import "./FancyBorder.css"; 2 | export default function FancyBorder(props) 3 | { 4 | console.log("Children ",props.children); 5 | return( 6 |
7 | {props.header} 8 | {props.children} 9 |
) 10 | } -------------------------------------------------------------------------------- /typescript/overload.ts: -------------------------------------------------------------------------------- 1 | function makeDate(timestamp: number): Date; 2 | function makeDate(mOrTimestamp: number, d: number): Date; 3 | function makeDate(m: number, d?: number): Date{ 4 | console.log("Date "); 5 | return new Date(); 6 | } 7 | const d1 = makeDate(12345678); 8 | const d2 = makeDate(5, 5); 9 | const d3 = makeDate(1,2); -------------------------------------------------------------------------------- /react-frontend/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /typescript/unition_2.ts: -------------------------------------------------------------------------------- 1 | function printId(id: number | string) { 2 | if (typeof id === "string") { 3 | // In this branch, id is of type 'string' 4 | console.log(id.toUpperCase()); 5 | } else { 6 | // Here, id is of type 'number' 7 | console.log(id* 30); 8 | } 9 | } 10 | 11 | printId("Hello"); 12 | printId(3) -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /typescript/constraint.js: -------------------------------------------------------------------------------- 1 | function longest(a, b) { 2 | if (a.length >= b.length) { 3 | return a; 4 | } 5 | else { 6 | return b; 7 | } 8 | } 9 | ; 10 | var max = longest([1, 2, 3, 4], [2, 3,]); 11 | console.log("Max ", max); 12 | var maxStr = longest("Hello", "Hi"); 13 | console.log("Max Str ", maxStr); 14 | -------------------------------------------------------------------------------- /typescript/construct_sing.js: -------------------------------------------------------------------------------- 1 | function fn(ctor) { 2 | return new ctor("hello"); 3 | } 4 | var Human = /** @class */ (function () { 5 | function Human(str) { 6 | this.name = str; 7 | console.log("Human ", str); 8 | } 9 | return Human; 10 | }()); 11 | var obj = fn(Human); 12 | console.log('Obj ', obj); 13 | -------------------------------------------------------------------------------- /typescript/null.ts: -------------------------------------------------------------------------------- 1 | function doSomething(x: string | null) { 2 | if (x === null) { 3 | // do nothing 4 | } else { 5 | console.log("Hello, " + x.toUpperCase()); 6 | } 7 | } 8 | doSomething("Jhon"); 9 | 10 | function liveDangerously(x?: number | null) { 11 | 12 | console.log(x!.toFixed()); 13 | } 14 | liveDangerously(12); -------------------------------------------------------------------------------- /typescript/rest.js: -------------------------------------------------------------------------------- 1 | function multiply(n) { 2 | var m = []; 3 | for (var _i = 1; _i < arguments.length; _i++) { 4 | m[_i - 1] = arguments[_i]; 5 | } 6 | return m.map(function (x) { return n * x; }); 7 | } 8 | // 'a' gets value [10, 20, 30, 40] 9 | var a = multiply(10, 1, 2, 3, 4); 10 | console.log('A ', a); 11 | -------------------------------------------------------------------------------- /StaticType.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | 6 | int main() 7 | { 8 | int a = 24; 9 | cout<<"A is "< 2 | 13 | -------------------------------------------------------------------------------- /typescript/anno.ts: -------------------------------------------------------------------------------- 1 | const names = ["Alice", "Bob", "Eve"]; 2 | names.forEach(function (s) { 3 | console.log(s.toUpperCase()); 4 | 5 | }); 6 | function display(obj:{ 7 | name : string, 8 | age? : number 9 | }) 10 | { 11 | console.log('Obj ',obj); 12 | } 13 | display({name : "TK",age : 38}); 14 | 15 | display({name : "TK"}); -------------------------------------------------------------------------------- /chapter16/AsyncRead.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | let start = new Date(); 3 | console.log("Start"); 4 | let p1 = fs.promises.readFile('hello.txt'); 5 | let p2 = fs.promises.readFile('hello2.txt'); 6 | Promise.all([p1,p2]).then(data=>{ 7 | let end = new Date(); 8 | let time = end- start; 9 | console.log("Time ",time); 10 | }) 11 | -------------------------------------------------------------------------------- /typescript/constraint.ts: -------------------------------------------------------------------------------- 1 | function longest(a: Type, b: Type) { 2 | if (a.length >= b.length) { 3 | return a; 4 | } else { 5 | return b; 6 | } 7 | }; 8 | let max = longest([1,2,3,4],[2,3,]); 9 | console.log("Max ",max); 10 | 11 | let maxStr = longest("Hello","Hi"); 12 | console.log("Max Str ",maxStr); -------------------------------------------------------------------------------- /typescript/function_type.ts: -------------------------------------------------------------------------------- 1 | type Predicate = (data:any)=>boolean 2 | 3 | let isEven:Predicate = (num)=> num %2 == 0; 4 | console.log("IsEven ",isEven(30)); 5 | 6 | type HigherOrder =( fun : Predicate)=>any 7 | 8 | let something: HigherOrder = function( fun:Predicate) 9 | { 10 | return fun; 11 | } 12 | console.log(something(isEven)(300)); -------------------------------------------------------------------------------- /typescript/unition_2.js: -------------------------------------------------------------------------------- 1 | function printId(id) { 2 | if (typeof id === "string") { 3 | // In this branch, id is of type 'string' 4 | console.log(id.toUpperCase()); 5 | } 6 | else { 7 | // Here, id is of type 'number' 8 | console.log(id * 30); 9 | } 10 | } 11 | printId("Hello"); 12 | printId(3); 13 | -------------------------------------------------------------------------------- /chapter11/Garbage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | -------------------------------------------------------------------------------- /chapter16/server.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | 3 | const requestListener = function (req, res) { 4 | console.log('Req ',req.headers); 5 | console.log('Url ',req.url); 6 | res.writeHead(200); 7 | res.end('Hello, World!'); 8 | } 9 | 10 | const server = http.createServer(requestListener); 11 | server.listen(8080); 12 | console.log('Ok'); -------------------------------------------------------------------------------- /chapter3/Equality.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /chapter6/Problem.html: -------------------------------------------------------------------------------- 1 | 2 | 12 | -------------------------------------------------------------------------------- /chapter8/IIFE.html: -------------------------------------------------------------------------------- 1 | 2 | 14 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/features/auth/authApi.js: -------------------------------------------------------------------------------- 1 | import {API_URL} from "../../setting/API"; 2 | import axios from "../../setting/our_axios"; 3 | 4 | export function login(username,password){ 5 | const loginUrl = API_URL+"users/login"; 6 | return axios.post(loginUrl,{ 7 | userName: username, 8 | password 9 | }); 10 | } -------------------------------------------------------------------------------- /chapter15/PreSelected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /react-frontend/src/components/tab/Tab.css: -------------------------------------------------------------------------------- 1 | .header 2 | { 3 | border:1px solid gray; 4 | padding :15px; 5 | font-weight: bold; 6 | } 7 | .active 8 | { 9 | color: #0a53be; 10 | } 11 | .tab-body 12 | { 13 | margin-top:15px; 14 | border:1px solid gray; 15 | border-radius: 10px; 16 | min-height: 200px; 17 | min-width: 500px; 18 | } -------------------------------------------------------------------------------- /react-redux-fourth-batch/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /backend/controller/User.js: -------------------------------------------------------------------------------- 1 | function hello(req,res,next) 2 | { 3 | res.json({ 4 | name : "Hello" 5 | }); 6 | } 7 | function saveUser(req,res,next) 8 | { 9 | console.log("User ",req.body); 10 | let user = req.body; 11 | user.id = 100; 12 | res.status(200).send(user); 13 | } 14 | module.exports = { 15 | hello, 16 | saveUser 17 | } -------------------------------------------------------------------------------- /chapter5/With.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | -------------------------------------------------------------------------------- /chapter7/UndefinedEmpty.html: -------------------------------------------------------------------------------- 1 | 2 | 12 | -------------------------------------------------------------------------------- /fp/Abstraction.html: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /typescript/assign.ts: -------------------------------------------------------------------------------- 1 | type voidFunc = () => void; 2 | 3 | const f1: voidFunc = () => { 4 | return true; 5 | }; 6 | 7 | const f2: voidFunc = () => true; 8 | 9 | const f3: voidFunc = function () { 10 | return true; 11 | }; 12 | 13 | let k = f1(); 14 | //k = "someting"; 15 | console.log('F1 ',f1()); 16 | console.log('F2 ',f2()); 17 | console.log('F3 ',f3()); -------------------------------------------------------------------------------- /chapter11/Url.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | -------------------------------------------------------------------------------- /chapter7/Concat.html: -------------------------------------------------------------------------------- 1 | 2 | 14 | -------------------------------------------------------------------------------- /chapter7/Flat.html: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /Dynamic.html: -------------------------------------------------------------------------------- 1 | 2 | 15 | -------------------------------------------------------------------------------- /chapter3/Global.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /chapter4/Operator.html: -------------------------------------------------------------------------------- 1 | 2 | 14 | -------------------------------------------------------------------------------- /fp/HOF.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/features/movies/Movie.css: -------------------------------------------------------------------------------- 1 | .movie 2 | { 3 | border: 1px solid lightgray; 4 | border-radius: 10px; 5 | margin-left:50px; 6 | margin-right: 50px; 7 | margin-bottom: 5px; 8 | } 9 | .movie-title 10 | { 11 | align-items: center; 12 | font-weight: bold; 13 | } 14 | .movie-body 15 | { 16 | padding-bottom: 10px; 17 | 18 | } -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter11/Intl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | -------------------------------------------------------------------------------- /chapter5/While.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | -------------------------------------------------------------------------------- /chapter8/Property.html: -------------------------------------------------------------------------------- 1 | 2 | 12 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/features/todos/todoAPI.js: -------------------------------------------------------------------------------- 1 | export function saveToDoApi(id) { 2 | return new Promise((resolve) => 3 | setTimeout(() => resolve({ id,text:"Dummy" }), 500) 4 | ); 5 | } 6 | export async function apiFetchAllTodos() 7 | { 8 | let response = await fetch('https://jsonplaceholder.typicode.com/todos/'); 9 | return response.json(); 10 | } -------------------------------------------------------------------------------- /typescript/alias.ts: -------------------------------------------------------------------------------- 1 | type Point = { 2 | x: number; 3 | y: number; 4 | }; 5 | 6 | // Exactly the same as the earlier example 7 | function printCoord(pt: Point) { 8 | console.log("The coordinate's x value is " + pt.x); 9 | console.log("The coordinate's y value is " + pt.y); 10 | } 11 | 12 | printCoord({ x: 100, y: 100 }); 13 | 14 | type size = number; 15 | let data : size; -------------------------------------------------------------------------------- /typescript/generic.ts: -------------------------------------------------------------------------------- 1 | class Stack 2 | { 3 | items : Array = []; 4 | 5 | push(ele : Type) 6 | { 7 | this.items.push(ele); 8 | } 9 | pop():Type|undefined 10 | { 11 | return this.items.pop(); 12 | } 13 | } 14 | let stack = new Stack(); 15 | stack.push(10); 16 | //stack.push("20"); 17 | console.log("Pop ",stack.pop()); -------------------------------------------------------------------------------- /chapter14/Template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 | 17 | -------------------------------------------------------------------------------- /fp/Flatten.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/features/movies/Movie.css: -------------------------------------------------------------------------------- 1 | .movie 2 | { 3 | border:1px solid lightgray; 4 | margin-top: 10px; 5 | margin-bottom: 10px; 6 | margin-left: 50px; 7 | margin-right: 50px; 8 | border-radius: 10px; 9 | min-height: 100px; 10 | } 11 | .movie-title 12 | { 13 | font-weight: bold; 14 | border-bottom: 1px solid lightgray; 15 | } -------------------------------------------------------------------------------- /chapter3/Boolean.html: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /react-frontend/src/components/function_component/hook/ContextHookDemo.js: -------------------------------------------------------------------------------- 1 | import React,{useContext} from 'react'; 2 | import ThemeContext from "../../context/ThemeContext"; 3 | 4 | 5 | export default function ContextHookDemo(props) 6 | { 7 | const theme = useContext(ThemeContext); 8 | return (
9 | Context Hook Demo foreground {theme.foreground} 10 |
); 11 | } -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/features/auth/authApi.ts: -------------------------------------------------------------------------------- 1 | import {API_URL} from "../../setting/API"; 2 | import axios from "../../setting/our_axios"; 3 | 4 | 5 | 6 | 7 | export function login(username:string,password:string){ 8 | const loginUrl = API_URL+"/users/login"; 9 | return axios.post(loginUrl,{ 10 | userName: username, 11 | password 12 | }); 13 | } -------------------------------------------------------------------------------- /fp/MayBeProblem.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | -------------------------------------------------------------------------------- /chapter13/FileRead.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | console.log('Before file read'); 3 | fs.readFile('hello.txt', 'utf8', (err, data) => { 4 | if (err) { 5 | console.error(err); 6 | return; 7 | } 8 | console.log("File name completed",data); 9 | fs.readFile(data,'utf-8',(err2,data2)=>{ 10 | console.log("File content ",data2) 11 | }) 12 | }); 13 | console.log('After file read'); -------------------------------------------------------------------------------- /chapter16/os.js: -------------------------------------------------------------------------------- 1 | const os = require("os"); 2 | 3 | console.log("Arch ",os.arch()); 4 | console.log("Constant ",os.constants); 5 | console.log("cpus ",os.cpus()); 6 | console.log("os.endianness ",os.endianness()); 7 | console.log("os.eol ",os.EOL); 8 | console.log("os.freeMemory ",os.freemem()); 9 | console.log("os.homedir ",os.homedir()); 10 | console.log("os.netwroks ",os.networkInterfaces()); 11 | -------------------------------------------------------------------------------- /chapter8/Namespace.html: -------------------------------------------------------------------------------- 1 | 2 | 16 | -------------------------------------------------------------------------------- /chapter13/FetchDemo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | -------------------------------------------------------------------------------- /chapter13/PromiseChain.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | -------------------------------------------------------------------------------- /chapter5/Statement.html: -------------------------------------------------------------------------------- 1 | 2 | 19 | -------------------------------------------------------------------------------- /chapter7/IndexOf.html: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /react-frontend/src/components/ListDemo.js: -------------------------------------------------------------------------------- 1 | function Item(props) { 2 | return
3 | {props.item} 4 |
; 5 | } 6 | 7 | export default function ListDemo() 8 | { 9 | let items = ["Task1 ","Task 2","Task3"]; 10 | return (
11 | { 12 | items.map((item,index)=> 13 | ) 14 | } 15 |
); 16 | } -------------------------------------------------------------------------------- /typescript/call_sing.ts: -------------------------------------------------------------------------------- 1 | type DescribableFunction = { 2 | description: string; 3 | (someArg: number): boolean; 4 | }; 5 | function doSomething(fn: DescribableFunction) { 6 | console.log(fn.description + " returned " + fn(6)); 7 | } 8 | function isEven(num:number) 9 | { 10 | return num % 2 ==0; 11 | } 12 | isEven.description = "Is even check a number is even or not"; 13 | doSomething(isEven); 14 | -------------------------------------------------------------------------------- /chapter4/Comparison.html: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /react-frontend/src/components/Avatar.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | export default class Avatar extends React.Component 3 | { 4 | constructor(props) { 5 | super(props); 6 | 7 | } 8 | 9 | render() { 10 | let profile = this.props.profile; 11 | //profile.name = "Something"; 12 | return(
13 | Avatar {profile.name} 14 |
) ; 15 | } 16 | } -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/app/hooks.ts: -------------------------------------------------------------------------------- 1 | import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'; 2 | import type { RootState, AppDispatch } from './store'; 3 | 4 | // Use throughout your app instead of plain `useDispatch` and `useSelector` 5 | export const useAppDispatch = () => useDispatch(); 6 | export const useAppSelector: TypedUseSelectorHook = useSelector; 7 | -------------------------------------------------------------------------------- /chapter8/RestParameter.html: -------------------------------------------------------------------------------- 1 | 2 | 16 | -------------------------------------------------------------------------------- /chapter8/multi_return.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func hello() (int, int) { 6 | return 10, 20 7 | } 8 | func fileRead() (int, error) { 9 | return 10, fmt.Errorf("Error") 10 | } 11 | func main() { 12 | var a int 13 | var b int 14 | a, b = hello() 15 | fmt.Println("A ", a, " b ", b) 16 | 17 | c, err := fileRead() 18 | if err != nil { 19 | fmt.Print("Have error ", c) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter15/fworker.js: -------------------------------------------------------------------------------- 1 | 2 | function fact(n) 3 | { 4 | if(n==0) 5 | { 6 | return 1; 7 | } 8 | else 9 | { 10 | return fact(n-1)*n; 11 | } 12 | } 13 | onmessage = (event)=>{ 14 | console.log('Event in factorial worker ',event.data); 15 | let n = event.data; 16 | let result = fact(n); 17 | postMessage(result); 18 | }; 19 | console.log('Worker Factorial .js loaded...'); -------------------------------------------------------------------------------- /chapter7/ReadWrite.html: -------------------------------------------------------------------------------- 1 | 2 | 15 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/features/reviews/reviewApi.js: -------------------------------------------------------------------------------- 1 | import {API_URL} from "../../setting/API"; 2 | /*import {Movie} from "./movieSlice";*/ 3 | import axios from "../../setting/our_axios"; 4 | 5 | 6 | const API = API_URL+"reviews/movie" 7 | 8 | export function apiGetAllReviewByMovie(movieId){ 9 | console.log('Called apiGetAllReviewByMovie with axios'); 10 | return axios.get(API+'/'+movieId); 11 | } 12 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/features/todos/ToDoCount.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { useSelector, useDispatch } from 'react-redux'; 3 | import {selectToDo} from "./todoSlice"; 4 | export default function ToDoCount(props) 5 | { 6 | const todos = useSelector(selectToDo); 7 | const dispatch = useDispatch(); 8 | return(
9 | To Do Count {todos.length} 10 |
) 11 | } -------------------------------------------------------------------------------- /chapter16/ReadSync.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | let start = new Date(); 3 | 4 | try { 5 | console.log("Start"); 6 | const data = fs.readFileSync('hello.txt', 'utf8'); 7 | //console.log(data); 8 | const data2 = fs.readFileSync('hello2.txt', 'utf8'); 9 | let end = new Date(); 10 | let time = end- start; 11 | console.log("Time ",time); 12 | } catch (err) { 13 | console.error(err); 14 | } 15 | -------------------------------------------------------------------------------- /chapter8/StackClousre.html: -------------------------------------------------------------------------------- 1 | 2 | 15 | -------------------------------------------------------------------------------- /fp/Monoid.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | -------------------------------------------------------------------------------- /typescript/super.ts: -------------------------------------------------------------------------------- 1 | class Human 2 | { 3 | name : string; 4 | constructor(name :string) 5 | { 6 | this.name = name; 7 | console.log('Human constructor'); 8 | 9 | } 10 | } 11 | class Teacher extends Human 12 | { 13 | constructor(name : string) 14 | { 15 | super(name); 16 | console.log('Teacher constructor',this.name); 17 | } 18 | } 19 | let teacher = new Teacher('Tk'); -------------------------------------------------------------------------------- /react-frontend/src/components/function_component/hook/UseLayoutDemo.js: -------------------------------------------------------------------------------- 1 | import React, {Suspense, useLayoutEffect,useDebugValue} from 'react'; 2 | 3 | export default function UseLayoutDemo(props) 4 | { 5 | useDebugValue('Demo debug value'); 6 | console.log("Use render"); 7 | useLayoutEffect(()=>{ 8 | console.log("Run layout"); 9 | }); 10 | return (
11 | Use Layout Demo 12 |
); 13 | } -------------------------------------------------------------------------------- /chapter16/exec.js: -------------------------------------------------------------------------------- 1 | const child_process = require("child_process"); const util = require("util"); 2 | const execP = util.promisify(child_process.exec); 3 | function parallelExec(commands) { 4 | 5 | let promises = commands.map(command => execP(command, {encoding: "utf8"})); 6 | 7 | return Promise.all(promises) 8 | .then(outputs => outputs.map(out => console.log(out))); 9 | } 10 | parallelExec(["ls -l *.js","ls -la"]); -------------------------------------------------------------------------------- /chapter3/ObjectDest.html: -------------------------------------------------------------------------------- 1 | 2 | 15 | -------------------------------------------------------------------------------- /chapter4/Default.html: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /chapter5/Declaration.html: -------------------------------------------------------------------------------- 1 | 2 | 16 | -------------------------------------------------------------------------------- /typescript/construct_sing.ts: -------------------------------------------------------------------------------- 1 | 2 | type SomeConstructor = { 3 | new (s: string): Human; 4 | }; 5 | function fn(ctor: SomeConstructor) { 6 | return new ctor("hello"); 7 | } 8 | 9 | class Human 10 | { 11 | name : string; 12 | constructor(str:string) 13 | { 14 | this.name = str; 15 | console.log("Human ",str); 16 | } 17 | } 18 | let obj = fn(Human); 19 | console.log('Obj ',obj); 20 | //obj = fn(Date); -------------------------------------------------------------------------------- /chapter15/LocalStorage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /chapter7/ArrToString.html: -------------------------------------------------------------------------------- 1 | 2 | 16 | -------------------------------------------------------------------------------- /react-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /chapter5/Frequency.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | -------------------------------------------------------------------------------- /typescript/runtime_this.js: -------------------------------------------------------------------------------- 1 | var MyClass = /** @class */ (function () { 2 | function MyClass() { 3 | this.name = "MyClass"; 4 | } 5 | MyClass.prototype.getName = function () { 6 | return this.name; 7 | }; 8 | return MyClass; 9 | }()); 10 | var c = new MyClass(); 11 | var obj = { 12 | name: "obj", 13 | getName: c.getName 14 | }; 15 | // Prints "obj", not "MyClass" 16 | console.log(obj.getName()); 17 | -------------------------------------------------------------------------------- /react-frontend/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /react-frontend/src/routes/ProtectedRoute.js: -------------------------------------------------------------------------------- 1 | import {Navigate} from "react-router-dom"; 2 | const ProtectedRoute = ({ 3 | user, 4 | redirectPath = '/login', 5 | children, 6 | }) => { 7 | if (!user) { 8 | return ; 9 | } 10 | 11 | return children; 12 | }; 13 | export default ProtectedRoute; -------------------------------------------------------------------------------- /react-redux-fourth-batch/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /typescript/structural_typing.ts: -------------------------------------------------------------------------------- 1 | type Animal= { 2 | name : string 3 | }; 4 | type Human = { 5 | name : string, 6 | age : number, 7 | work : ()=>any 8 | } 9 | 10 | let data:Animal = { 11 | name: "Something" 12 | } 13 | let another : Human = { 14 | name : "Another", 15 | age : 30, 16 | work : function() 17 | { 18 | console.log("Work "); 19 | } 20 | } 21 | data = another; 22 | console.log("Data ",data); -------------------------------------------------------------------------------- /chapter11/RegEmail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | -------------------------------------------------------------------------------- /chapter6/Acces.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | -------------------------------------------------------------------------------- /react-frontend/src/components/context/ThemeContext.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | export const themes = { 3 | light: { 4 | foreground: '#000000', 5 | background: '#eeeeee', 6 | }, 7 | dark: { 8 | foreground: '#ffffff', 9 | background: '#222222', 10 | }, 11 | }; 12 | const ThemeContext = React.createContext(themes.dark); 13 | ThemeContext.displayName = "ThemeContextName"; 14 | export default ThemeContext; -------------------------------------------------------------------------------- /react-frontend/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /typescript/gen_fun.ts: -------------------------------------------------------------------------------- 1 | function firstElement(arr: Type[]): Type | undefined { 2 | return arr[0]; 3 | } 4 | let ele = firstElement([1,2,3]); 5 | console.log('Ele ',ele); 6 | 7 | let str = firstElement(["helo","how"]); 8 | console.log('Str ',str); 9 | 10 | function map(arr: Input[], func: (arg: Input) => Output): Output[] { 11 | return arr.map(func); 12 | } 13 | const parsed = map(["1", "2", "3"], (n) => parseInt(n)); -------------------------------------------------------------------------------- /chapter16/event.js: -------------------------------------------------------------------------------- 1 | const {EventEmitter} = require("events"); 2 | //console.log("Event emitter ",EventEmitter); 3 | 4 | const firstEmitter = new EventEmitter(); 5 | 6 | function someTask() 7 | { 8 | setTimeout(()=>{ 9 | firstEmitter.emit("taskCompleted",{data:"Something"}); 10 | },2000); 11 | } 12 | firstEmitter.on("taskCompleted",(data)=>{ 13 | console.log("On task compelted",data); 14 | }); 15 | console.log('Task start'); 16 | someTask(); -------------------------------------------------------------------------------- /fp/curry_with_ramda.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | -------------------------------------------------------------------------------- /react-frontend/src/components/fragment/FragmentDemo.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default class FragmentDemo extends React.Component 4 | { 5 | render() { 6 | return ( 7 | 8 |
9 | One 10 |
11 |
12 | Two 13 |
14 |
15 | ); 16 | } 17 | } -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /typescript/arrow.ts: -------------------------------------------------------------------------------- 1 | class MyClass { 2 | name = "MyClass"; 3 | /* 4 | getName = () => { 5 | return this.name; 6 | }; 7 | */ 8 | getName () 9 | { 10 | return this.name; 11 | } 12 | method(this:MyClass,msg : string) 13 | { 14 | console.log("This ",this , ' msg ',msg); 15 | } 16 | } 17 | const c = new MyClass(); 18 | const g = c.getName; 19 | // Prints "MyClass" instead of crashing 20 | console.log(g()); 21 | 22 | c.method('Hello'); -------------------------------------------------------------------------------- /chapter15/SessionStorage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /chapter2/Identifier.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | -------------------------------------------------------------------------------- /chapter3/Destructuring.html: -------------------------------------------------------------------------------- 1 | 2 | 19 | -------------------------------------------------------------------------------- /chapter5/LabelledLoop.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | -------------------------------------------------------------------------------- /chapter5/Yield.html: -------------------------------------------------------------------------------- 1 | 2 | 16 | -------------------------------------------------------------------------------- /chapter6/ShorthandMethod.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | -------------------------------------------------------------------------------- /chapter8/ArgumentPar.html: -------------------------------------------------------------------------------- 1 | 2 | 16 | -------------------------------------------------------------------------------- /chapter8/Optional.html: -------------------------------------------------------------------------------- 1 | 2 | 19 | -------------------------------------------------------------------------------- /react-frontend/src/components/render-property/Cat.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | export default class Cat extends React.Component { 4 | render() { 5 | const mouse = this.props.mouse; 6 | return ( 7 | 8 | ); 9 | } 10 | } 11 | Cat.propTypes = { 12 | mouse: PropTypes.object.isRequired 13 | }; -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /typescript/generic.js: -------------------------------------------------------------------------------- 1 | var Stack = /** @class */ (function () { 2 | function Stack() { 3 | this.items = []; 4 | } 5 | Stack.prototype.push = function (ele) { 6 | this.items.push(ele); 7 | }; 8 | Stack.prototype.pop = function () { 9 | return this.items.pop(); 10 | }; 11 | return Stack; 12 | }()); 13 | var stack = new Stack(); 14 | stack.push(10); 15 | //stack.push("20"); 16 | console.log("Pop ", stack.pop()); 17 | -------------------------------------------------------------------------------- /backend/model/user.js: -------------------------------------------------------------------------------- 1 | //Filename: Posts.js 2 | const mongoose = require('mongoose'); 3 | const Schema = mongoose.Schema; 4 | const UserSchema = new Schema({ 5 | username: { 6 | type: 'String', 7 | required: true, 8 | trim: true, 9 | unique: true 10 | }, 11 | password: { 12 | type: 'String', 13 | required: true, 14 | trim: true 15 | } 16 | }); 17 | module.exports = mongoose.model('User', UserSchema) -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import { Provider } from 'react-redux'; 4 | import { store } from './app/store'; 5 | import App from './App'; 6 | 7 | test('renders learn react link', () => { 8 | const { getByText } = render( 9 | 10 | 11 | 12 | ); 13 | 14 | expect(getByText(/learn/i)).toBeInTheDocument(); 15 | }); 16 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/services/authService.ts: -------------------------------------------------------------------------------- 1 | import { useAppSelector, useAppDispatch } from '../app/hooks'; 2 | import {selectAuth} from "../features/auth/authSlice"; 3 | 4 | export default function useAuth() 5 | { 6 | let authUser = useAppSelector(selectAuth); 7 | console.log("Use Auth user",authUser); 8 | return authUser; 9 | } 10 | export function useAuthentication() 11 | { 12 | let authUser = useAuth(); 13 | return authUser.token; 14 | } -------------------------------------------------------------------------------- /backend/routes/movies.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | var movies = require('./../controller/MovieController'); 4 | 5 | router.get('/', movies.getAllMovie); 6 | router.get('/:movieId', movies.getMovieById); 7 | router.get('/title/:title',movies.findMovieByTitle); 8 | router.post('/',movies.newMovie); 9 | router.put('/:movieId',movies.updateMovie); 10 | router.delete('/:movieId',movies.deleteMovie); 11 | 12 | module.exports = router; -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import { Provider } from 'react-redux'; 4 | import { store } from './app/store'; 5 | import App from './App'; 6 | 7 | test('renders learn react link', () => { 8 | const { getByText } = render( 9 | 10 | 11 | 12 | ); 13 | 14 | expect(getByText(/learn/i)).toBeInTheDocument(); 15 | }); 16 | -------------------------------------------------------------------------------- /chapter5/UseStrict.html: -------------------------------------------------------------------------------- 1 | 2 | 22 | -------------------------------------------------------------------------------- /fp/Once.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | -------------------------------------------------------------------------------- /Pragmatic.html: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /backend/routes/reviews.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | var review = require('./../controller/ReviewController'); 4 | 5 | 6 | router.get('/', review.getAllReview); 7 | router.get('/movie/:movieId',review.getReviewByMovieId); 8 | router.get('/:reviewId', review.getReviewById); 9 | router.post('/',review.saveReview); 10 | router.put('/:reviewId',review.updateReview); 11 | router.delete('/:reviewId',review.deleteReview); 12 | module.exports = router; -------------------------------------------------------------------------------- /chapter16/fetch_data.js: -------------------------------------------------------------------------------- 1 | const https = require("https"); 2 | 3 | 4 | const options = { 5 | hostname: 'jsonplaceholder.typicode.com', 6 | port: 443, 7 | path: '/todos/1', 8 | method: 'GET', 9 | }; 10 | 11 | const req = https.request(options, res => { 12 | console.log(`statusCode: ${res.statusCode}`); 13 | 14 | res.on('data', d => { 15 | process.stdout.write(d); 16 | }); 17 | }); 18 | 19 | req.on('error', error => { 20 | console.error(error); 21 | }); 22 | 23 | req.end(); -------------------------------------------------------------------------------- /chapter3/Arithmetic.html: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /chapter8/FunctionExpression.html: -------------------------------------------------------------------------------- 1 | 2 | 23 | -------------------------------------------------------------------------------- /typescript/composite.ts: -------------------------------------------------------------------------------- 1 | type LeafNode = { 2 | data : string 3 | }; 4 | type SubTree = { 5 | children : Array 6 | } 7 | type Tree = LeafNode | SubTree; 8 | 9 | let tree : Tree = { 10 | children : [ 11 | { 12 | data : "1" 13 | }, 14 | { 15 | children : [ 16 | { 17 | data : "1" 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | console.log("Tree ",tree); -------------------------------------------------------------------------------- /backend/model/Review.js: -------------------------------------------------------------------------------- 1 | //Filename: Posts.js 2 | const mongoose = require('mongoose'); 3 | const Schema = mongoose.Schema; 4 | const ReviewSchema = new Schema({ 5 | movie: { 6 | type: Schema.Types.ObjectId, 7 | ref: "Movies" 8 | }, 9 | rating: { 10 | type: Number, 11 | required: true, 12 | }, 13 | review: { 14 | type: String, 15 | required: true, 16 | }, 17 | 18 | }); 19 | module.exports = mongoose.model('Reviews', ReviewSchema); -------------------------------------------------------------------------------- /chapter8/Bind.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | -------------------------------------------------------------------------------- /chapter9/DuckTyping.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 25 | -------------------------------------------------------------------------------- /react-frontend/src/components/WelcomeDialog.js: -------------------------------------------------------------------------------- 1 | import FancyBorder from "./FancyBorder"; 2 | export default function WelcomeDialog() { 3 | let header =

This is header

; 4 | return ( 5 | 6 |

7 | Welcome 8 |

9 |

10 | Thank you for visiting our spacecraft! 11 |

12 |
13 | ); 14 | } -------------------------------------------------------------------------------- /chapter4/In.html: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /chapter8/ClosureProblem.html: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /chapter13/PromiseAsErrorHandling.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | -------------------------------------------------------------------------------- /chapter2/Literal.html: -------------------------------------------------------------------------------- 1 | 2 | 19 | -------------------------------------------------------------------------------- /chapter5/Break.html: -------------------------------------------------------------------------------- 1 | 2 | 24 | -------------------------------------------------------------------------------- /typescript/static.ts: -------------------------------------------------------------------------------- 1 | class MyClass { 2 | static x = 0; 3 | static{ 4 | console.log('Static block'); 5 | } 6 | constructor() 7 | { 8 | MyClass.x ++; 9 | console.log('Constructor'); 10 | } 11 | print() 12 | { 13 | console.log('x is ',MyClass.x); 14 | } 15 | static printX() { 16 | console.log(MyClass.x); 17 | } 18 | } 19 | console.log(MyClass.x); 20 | MyClass.printX(); 21 | 22 | let obj = new MyClass(); 23 | obj.print(); 24 | 25 | let obj2 = new MyClass(); 26 | obj.print(); 27 | -------------------------------------------------------------------------------- /chapter11/TypeArray.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | -------------------------------------------------------------------------------- /chapter16/hello.ts: -------------------------------------------------------------------------------- 1 | let a = 10; 2 | 3 | //a = "Hello"; 4 | console.log("A ",a); 5 | 6 | let obj = { 7 | name : "TK", 8 | age : 37 9 | }; 10 | //console.log("Obj ",obj.nmae); 11 | 12 | let b :string | number = "hello"; 13 | //let x = b * 1; 14 | //console.log("X ",x); 15 | 16 | interface Human 17 | { 18 | name : string; 19 | } 20 | interface Teacher 21 | { 22 | subject: string; 23 | } 24 | type HumanTeacher = Human & Teacher; 25 | let obj2 : HumanTeacher = { 26 | name: "TK", 27 | subject : "Programming" 28 | } -------------------------------------------------------------------------------- /chapter8/FunctionCall.html: -------------------------------------------------------------------------------- 1 | 2 | 19 | -------------------------------------------------------------------------------- /react-frontend/.idea/react-frontend.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /chapter5/Return.html: -------------------------------------------------------------------------------- 1 | 2 | 21 | -------------------------------------------------------------------------------- /chapter8/Function.html: -------------------------------------------------------------------------------- 1 | 2 | 22 | -------------------------------------------------------------------------------- /backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "backend", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "node ./bin/www" 7 | }, 8 | "dependencies": { 9 | "bcrypt": "^5.0.1", 10 | "cookie-parser": "~1.4.4", 11 | "cors": "^2.8.5", 12 | "debug": "~2.6.9", 13 | "express": "~4.16.1", 14 | "http-errors": "~1.6.3", 15 | "jade": "~1.11.0", 16 | "jsonwebtoken": "^8.5.1", 17 | "mongoose": "^6.5.3", 18 | "morgan": "~1.9.1", 19 | "swagger-ui-express": "^4.5.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /fp/CustomCompose.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /react-frontend/src/components/Post.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Avatar from "./Avatar"; 3 | export default class Post extends React.Component 4 | { 5 | constructor(props) { 6 | super(props); 7 | } 8 | render() { 9 | let post = this.props.post; 10 | let profile = post.profile; 11 | return( 12 |
13 | {post.text} 14 | 15 |
Comment
16 |
17 | ); 18 | 19 | } 20 | } -------------------------------------------------------------------------------- /chapter6/Spread.html: -------------------------------------------------------------------------------- 1 | 2 | 21 | -------------------------------------------------------------------------------- /chapter9/Private.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | -------------------------------------------------------------------------------- /chapter8/Scope.html: -------------------------------------------------------------------------------- 1 | 2 | 19 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/.idea/react-redux-fourth-batch.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/features/movies/MovieListUI.tsx: -------------------------------------------------------------------------------- 1 | import {Movie} from "./movieSlice"; 2 | import './Movie.css'; 3 | export default function MovieListUI(props:{ 4 | movies : Array 5 | }) 6 | { 7 | return (
8 | { 9 | props.movies.map((movie:Movie)=>{ 10 | return (
11 |
{movie.title}
12 |
{movie.year}
13 |
); 14 | }) 15 | } 16 |
); 17 | } -------------------------------------------------------------------------------- /chapter15/Worker.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /react-frontend/src/components/HelloWorld.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | export default class HelloWorld extends React.Component 3 | { 4 | constructor(props) { 5 | super(props); 6 | } 7 | toUpper(str) 8 | { 9 | return str.toUpperCase(); 10 | } 11 | render() { 12 | 13 | let obj =this.props.obj; 14 | console.log("Render"); 15 | let element =
16 |

Hello {this.toUpper(obj.name)}

17 |
18 |
; 19 | 20 | return element; 21 | } 22 | } -------------------------------------------------------------------------------- /chapter15/LocalStorage2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /react-frontend/src/components/jsx/RepeatDemo.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function Repeat(props) { 4 | let items = []; 5 | for (let i = 0; i < props.numTimes; i++) { 6 | items.push(props.children(i)); 7 | } 8 | return
{items}
; 9 | } 10 | export default class RepeatDemo extends React.Component 11 | { 12 | render() { 13 | return ( 14 | 15 | {(index)=>
This is item {index} in the list
} 16 |
17 | ); 18 | } 19 | } -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/.idea/redux-typescript-fourth-batch.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/features/todo/todoApi.ts: -------------------------------------------------------------------------------- 1 | import {TodoItem} from "./todoSlice"; 2 | 3 | function jsonItemsToDoItems(items:Array):Array 4 | { 5 | return items.map((item:any)=> ({ 6 | id : item.id, 7 | text : item.title 8 | })); 9 | } 10 | export function apiGetAllTodos() 11 | { 12 | let url = 'https://jsonplaceholder.typicode.com/todos'; 13 | console.log('API ',url); 14 | return fetch(url) 15 | .then(response=>response.json()) 16 | .then(items=>jsonItemsToDoItems(items)); 17 | 18 | } -------------------------------------------------------------------------------- /chapter11/ConsoleError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/features/movies/MovieList.js: -------------------------------------------------------------------------------- 1 | import Movie from "./Movie"; 2 | import React from "react"; 3 | 4 | export default function MovieList({movieList,deleteBtnHandler,editHandler}) 5 | { 6 | return (
7 | { 8 | movieList.map(movie=>) 13 | } 14 |
); 15 | } -------------------------------------------------------------------------------- /chapter11/Endian.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | -------------------------------------------------------------------------------- /chapter11/Timer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | -------------------------------------------------------------------------------- /chapter16/process_api.js: -------------------------------------------------------------------------------- 1 | console.log("Argv ",process.argv); 2 | console.log("Arch ",process.arch); 3 | console.log("Cwd ",process.cwd()); 4 | console.log("CPU usage ",process.cpuUsage()); 5 | console.log("env ",process.env); 6 | console.log("execPath ",process.execPath); 7 | 8 | console.log("userid ",process.getuid()); 9 | console.log("memoryUsage ",process.memoryUsage()); 10 | process.nextTick(()=>{ 11 | console.log("Next tick"); 12 | }); 13 | console.log("End"); 14 | console.log("resource usage ",process.resourceUsage()); 15 | console.log("version ",process.versions); -------------------------------------------------------------------------------- /chapter8/NestedFunc.html: -------------------------------------------------------------------------------- 1 | 2 | 24 | -------------------------------------------------------------------------------- /chapter13/ForAwait.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | -------------------------------------------------------------------------------- /chapter3/Number.html: -------------------------------------------------------------------------------- 1 | 2 | 28 | -------------------------------------------------------------------------------- /chapter11/Reg7.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | -------------------------------------------------------------------------------- /chapter16/buffer.js: -------------------------------------------------------------------------------- 1 | let b = Buffer.from([0x41, 0x42, 0x43]); 2 | console.log("buffer toString ",b.toString()); 3 | console.log("buffer toString ",b.toString("hex")); 4 | 5 | let computer = Buffer.from("IBM3111", "ascii"); 6 | console.log(computer.subarray(0,3).map(x=>x+1).toString()); 7 | 8 | let zeros = Buffer.alloc(1024); 9 | 10 | let dead = Buffer.alloc(1024, "DEADBEEF", "hex"); 11 | console.log("dead.readUInt32BE(0) ",dead.readUInt32BE(0)); 12 | console.log("dead.readUInt32LE(0) ",dead.readUInt32LE(0)); 13 | 14 | console.log("dead.readBigUInt64BE(0) ",dead.readBigUInt64BE(0)); -------------------------------------------------------------------------------- /chapter4/Not.html: -------------------------------------------------------------------------------- 1 | 2 | 22 | -------------------------------------------------------------------------------- /chapter8/OtherMethod.html: -------------------------------------------------------------------------------- 1 | 2 | 24 | -------------------------------------------------------------------------------- /chapter9/StaticType.java: -------------------------------------------------------------------------------- 1 | interface Flyable 2 | { 3 | void fly(); 4 | } 5 | class Bird implements Flyable 6 | { 7 | public void fly() 8 | { 9 | System.out.println("Birdy Fly"); 10 | } 11 | } 12 | class Aeroplane implements Flyable 13 | { 14 | public void fly() 15 | { 16 | System.out.println("Aeroplane Fly"); 17 | } 18 | } 19 | public class StaticType 20 | { 21 | public static void main(String[]args) 22 | { 23 | Flyable b = new Bird(); 24 | b.fly(); 25 | 26 | b = new Aeroplane(); 27 | b.fly(); 28 | } 29 | } -------------------------------------------------------------------------------- /fp/Unary.html: -------------------------------------------------------------------------------- 1 | 2 | 21 | -------------------------------------------------------------------------------- /react-frontend/src/components/function_component/Greeting.js: -------------------------------------------------------------------------------- 1 | function UserGreeting(props) { 2 | return

Welcome back!

; 3 | } 4 | 5 | function GuestGreeting(props) { 6 | return

Please sign up.

; 7 | } 8 | export default function Greeting(props) { 9 | const isLoggedIn = props.isLoggedIn; 10 | let component = isLoggedIn? : ; 11 | /*return (
12 | {component} 13 |
);*/ 14 | return ( 15 |
16 | {isLoggedIn? : } 17 |
18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/services/authService.js: -------------------------------------------------------------------------------- 1 | //import { useAppSelector, useAppDispatch } from '../app/hooks'; 2 | //import {selectAuth} from "../features/auth/authSlice"; 3 | 4 | import {useSelector} from "react-redux"; 5 | import {selectAuth} from "../features/auth/authSlice"; 6 | 7 | /*export default function useAuth() 8 | { 9 | let authUser = useAppSelector(selectAuth); 10 | console.log("Use Auth user",authUser); 11 | return authUser; 12 | }*/ 13 | export function useAuthentication() 14 | { 15 | let authUser = useSelector(selectAuth); 16 | return authUser; 17 | } -------------------------------------------------------------------------------- /chapter4/Expression.html: -------------------------------------------------------------------------------- 1 | 2 | 23 | -------------------------------------------------------------------------------- /fp/Functor.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | -------------------------------------------------------------------------------- /chapter6/Literal.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | -------------------------------------------------------------------------------- /chapter8/Closure.html: -------------------------------------------------------------------------------- 1 | 2 | 24 | -------------------------------------------------------------------------------- /react-frontend/src/components/forward-ref/ForwardRefDemo.js: -------------------------------------------------------------------------------- 1 | import React, { Suspense } from 'react'; 2 | const FancyButton = React.forwardRef((props, ref) => ( 3 | 6 | )); 7 | export default class ForwardRefDemo extends React.Component 8 | { 9 | render() { 10 | const ref = React.createRef(); 11 | console.log("Ref ",ref); 12 | return ( 13 |
14 | 15 | Click me!; 16 |
17 | ); 18 | } 19 | } -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/routes/ProtectedRoute.js: -------------------------------------------------------------------------------- 1 | import React,{Component} from 'react'; 2 | import { 3 | Link, 4 | Route, 5 | Navigate, 6 | } from "react-router-dom"; 7 | export default function ProtectedRoute({ children, 8 | redirectTo, 9 | isAuth, 10 | path, ...props }) { 11 | console.log("Protected Route Render"); 12 | console.log('Is auth ',isAuth, ' redirectTo ',redirectTo); 13 | return isAuth ? children : ; 14 | } 15 | -------------------------------------------------------------------------------- /chapter6/Extend.html: -------------------------------------------------------------------------------- 1 | 2 | 22 | -------------------------------------------------------------------------------- /chapter7/Slice.html: -------------------------------------------------------------------------------- 1 | 2 | 23 | -------------------------------------------------------------------------------- /react-frontend/src/pages/Movie.js: -------------------------------------------------------------------------------- 1 | import {useNavigate, Outlet, Link} from "react-router-dom"; 2 | export default function Movie(props) 3 | { 4 | let navigate = useNavigate(); 5 | const goToDetailsHandler = ()=>{ 6 | navigate('/movies/100'); 7 | }; 8 | return (
9 | Movie 10 | 15 | 16 |   17 | To Details 18 | 19 | 20 |
) 21 | } -------------------------------------------------------------------------------- /typescript/arrow.js: -------------------------------------------------------------------------------- 1 | var MyClass = /** @class */ (function () { 2 | function MyClass() { 3 | this.name = "MyClass"; 4 | } 5 | /* 6 | getName = () => { 7 | return this.name; 8 | }; 9 | */ 10 | MyClass.prototype.getName = function () { 11 | return this.name; 12 | }; 13 | MyClass.prototype.method = function (msg) { 14 | console.log("This ", this, ' msg ', msg); 15 | }; 16 | return MyClass; 17 | }()); 18 | var c = new MyClass(); 19 | var g = c.getName; 20 | // Prints "MyClass" instead of crashing 21 | console.log(g()); 22 | c.method('Hello'); 23 | -------------------------------------------------------------------------------- /chapter11/Reg5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | -------------------------------------------------------------------------------- /chapter15/ClosureLeak.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 24 | 25 | -------------------------------------------------------------------------------- /chapter13/Await.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 25 | -------------------------------------------------------------------------------- /chapter6/Mapping.html: -------------------------------------------------------------------------------- 1 | 2 | 27 | -------------------------------------------------------------------------------- /chapter6/Create.html: -------------------------------------------------------------------------------- 1 | 2 | 23 | -------------------------------------------------------------------------------- /chapter7/MultiDimensionalArray.html: -------------------------------------------------------------------------------- 1 | 2 | 23 | -------------------------------------------------------------------------------- /fp/Zip.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | -------------------------------------------------------------------------------- /react-frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/app/store.js: -------------------------------------------------------------------------------- 1 | import { configureStore } from '@reduxjs/toolkit'; 2 | import counterReducer from '../features/counter/counterSlice'; 3 | import todoReducer from '../features/todos/todoSlice'; 4 | import movieReducer from '../features/movies/movieSlice'; 5 | import reviewReducer from '../features/reviews/reviewSlice'; 6 | import authReducer from '../features/auth/authSlice'; 7 | export const store = configureStore({ 8 | reducer: { 9 | counter: counterReducer, 10 | todos : todoReducer, 11 | movie: movieReducer, 12 | review: reviewReducer, 13 | auth : authReducer, 14 | }, 15 | }); 16 | -------------------------------------------------------------------------------- /fp/MonadProblem.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | -------------------------------------------------------------------------------- /react-frontend/src/components/function_component/hook/UseRefDemo.js: -------------------------------------------------------------------------------- 1 | import React, {useRef} from 'react'; 2 | 3 | export default function UseRefDemo() { 4 | const inputEl = useRef(null); 5 | const onButtonClick = () => { 6 | // `current` points to the mounted text input element 7 | inputEl.current.focus(); 8 | }; 9 | return ( 10 | <> 11 | 12 | 17 | 18 | ); 19 | } -------------------------------------------------------------------------------- /chapter9/ClassExpression.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 24 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /typescript/static.js: -------------------------------------------------------------------------------- 1 | var MyClass = /** @class */ (function () { 2 | function MyClass() { 3 | MyClass.x++; 4 | console.log('Constructor'); 5 | } 6 | MyClass.prototype.print = function () { 7 | console.log('x is ', MyClass.x); 8 | }; 9 | MyClass.printX = function () { 10 | console.log(MyClass.x); 11 | }; 12 | MyClass.x = 0; 13 | (function () { 14 | console.log('Static block'); 15 | })(); 16 | return MyClass; 17 | }()); 18 | console.log(MyClass.x); 19 | MyClass.printX(); 20 | var obj = new MyClass(); 21 | obj.print(); 22 | var obj2 = new MyClass(); 23 | obj.print(); 24 | -------------------------------------------------------------------------------- /chapter9/Class2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /chapter3/ObjectToPrimitive.html: -------------------------------------------------------------------------------- 1 | 2 | 26 | -------------------------------------------------------------------------------- /chapter4/Bitwise.html: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /fp/memonize.html: -------------------------------------------------------------------------------- 1 | 2 | 22 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/pages/LogoutPage.tsx: -------------------------------------------------------------------------------- 1 | import {useAppDispatch} from "../app/hooks"; 2 | import {useNavigate,useParams,useLocation} from "react-router-dom"; 3 | import {logout} from './../features/auth/authSlice'; 4 | export default function LogoutPage() 5 | { 6 | let navigate = useNavigate(); 7 | let dispatch = useAppDispatch(); 8 | let logoutHandler = ()=>{ 9 | console.log("Logout "); 10 | dispatch(logout()); 11 | navigate("/"); 12 | 13 | } 14 | return (
15 | 18 |
); 19 | } -------------------------------------------------------------------------------- /chapter14/Extensibility.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 25 | -------------------------------------------------------------------------------- /chapter10/IIFE_Module.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 26 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/features/movies/movieApi.js: -------------------------------------------------------------------------------- 1 | import {API_URL} from "../../setting/API"; 2 | /*import {Movie} from "./movieSlice";*/ 3 | import axios from "../../setting/our_axios"; 4 | 5 | 6 | const API = API_URL+"movies" 7 | 8 | export function apiGetAllMovie(){ 9 | console.log('Called getAllMovie with axios'); 10 | return axios.get(API); 11 | } 12 | export function apiSaveMovie(movie) 13 | { 14 | return axios.post(API,movie); 15 | } 16 | export function apiUpdateMovie(movie) 17 | { 18 | return axios.put(API+'/'+movie._id,movie); 19 | } 20 | export function apiDeleteMovie(movie) 21 | { 22 | return axios.delete(API+'/'+movie._id); 23 | } -------------------------------------------------------------------------------- /chapter11/ThreadDemo.java: -------------------------------------------------------------------------------- 1 | public class ThreadDemo extends Thread 2 | { 3 | String name; 4 | ThreadDemo(String name) 5 | { 6 | this.name = name; 7 | } 8 | public void run() 9 | { 10 | for(int i=0;i<30;i++) 11 | { 12 | System.out.println("Thread "+this.name+ " i "+i); 13 | } 14 | } 15 | public static void main(String[]args) 16 | { 17 | ThreadDemo t1 = new ThreadDemo("ThreadOne"); 18 | ThreadDemo t2 = new ThreadDemo("ThreadTwo"); 19 | ThreadDemo t3 = new ThreadDemo("ThreadThree"); 20 | 21 | t1.start(); 22 | t2.start(); 23 | t3.start(); 24 | } 25 | } -------------------------------------------------------------------------------- /chapter6/GetterSetter.html: -------------------------------------------------------------------------------- 1 | 2 | 24 | -------------------------------------------------------------------------------- /chapter7/Reduce.html: -------------------------------------------------------------------------------- 1 | 2 | 23 | -------------------------------------------------------------------------------- /fp/Predicate.html: -------------------------------------------------------------------------------- 1 | 2 | 25 | -------------------------------------------------------------------------------- /backend/model/Movie.js: -------------------------------------------------------------------------------- 1 | //Filename: Posts.js 2 | const mongoose = require('mongoose'); 3 | const Schema = mongoose.Schema; 4 | const MovieSchema = new Schema({ 5 | title: { 6 | type: String, 7 | required: true, 8 | }, 9 | director: { 10 | type:{ 11 | name:{ 12 | type: String, 13 | required: true, 14 | }, 15 | phoneNo:{ 16 | type: String 17 | } 18 | }, 19 | required:false, 20 | }, 21 | year: { 22 | type: Number, 23 | required: true, 24 | } 25 | }); 26 | module.exports = mongoose.model('Movies', MovieSchema); -------------------------------------------------------------------------------- /chapter16/path.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | let p = "src/pkg/test.js"; 3 | 4 | console.log('Basename ',path.basename(p)); 5 | console.log('path.extname ',path.extname(p)); 6 | console.log('path.dirname(p) ',path.dirname(p)); 7 | console.log('path.dirname(p) ',path.dirname(p)); 8 | console.log('path.basename(path.dirname(p)) ',path.basename(path.dirname(p))); 9 | console.log('path.dirname(path.dirname(p)) ',path.dirname(path.dirname(p))); 10 | 11 | console.log('path.normalize("a/b/c/../d/")',path.normalize("a/b/c/../d/")); 12 | console.log('path.join("src", "pkg", "t.js")',path.join("src", "pkg", "t.js")); 13 | console.log('path.resolve("t.js") ',path.resolve("path.js")); -------------------------------------------------------------------------------- /chapter8/ParameterPass.html: -------------------------------------------------------------------------------- 1 | 2 | 31 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/pages/MoviePage.tsx: -------------------------------------------------------------------------------- 1 | import {useAppDispatch, useAppSelector} from "../app/hooks"; 2 | import {selectToDo} from "../features/todo/todoSlice"; 3 | import {getAllMovie, selectMovie} from "../features/movies/movieSlice"; 4 | import MovieListUI from "../features/movies/MovieListUI"; 5 | import {useEffect} from "react"; 6 | 7 | export default function MoviePage() 8 | { 9 | const movies = useAppSelector(selectMovie); 10 | const dispatch = useAppDispatch(); 11 | 12 | useEffect(()=>{ 13 | dispatch(getAllMovie()); 14 | },[]); 15 | return (
16 | Movie Page 17 | 18 |
) 19 | } -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /chapter5/NestedArray.html: -------------------------------------------------------------------------------- 1 | 2 | 26 | -------------------------------------------------------------------------------- /chapter13/Event.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | -------------------------------------------------------------------------------- /chapter8/FunctionProperty.html: -------------------------------------------------------------------------------- 1 | 2 | 21 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/pages/LogoutPage.js: -------------------------------------------------------------------------------- 1 | import {useDispatch} from "react-redux"; 2 | import {logout} from "../features/auth/authSlice"; 3 | import {useNavigate} from "react-router-dom"; 4 | 5 | export default function LogoutPage(props) 6 | { 7 | const dispatch = useDispatch(); 8 | const navigate = useNavigate(); 9 | const logoutHandler = ()=>{ 10 | console.log('Logout handler'); 11 | dispatch(logout()); 12 | navigate("/"); 13 | } 14 | return (
15 | 20 |
) 21 | } -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/component/PrivateRoute.tsx: -------------------------------------------------------------------------------- 1 | import React,{Component} from 'react'; 2 | import { 3 | Link, 4 | Route, 5 | Navigate, 6 | } from "react-router-dom"; 7 | /* 8 | interface PrivateRouteParams{ 9 | element:Component, 10 | redirectTo:string, 11 | isAuth:boolean, 12 | path:string, 13 | props?:any 14 | }*/ 15 | export default function PrivateRoute({ children, 16 | redirectTo, 17 | isAuth, 18 | path, ...props }:any) { 19 | 20 | console.log('Is auth ',isAuth, ' redirectTo ',redirectTo); 21 | return isAuth ? children : ; 22 | } 23 | -------------------------------------------------------------------------------- /chapter15/DeattachedDOMLeak.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 26 | 27 | -------------------------------------------------------------------------------- /chapter3/Zero.html: -------------------------------------------------------------------------------- 1 | 2 | 22 | -------------------------------------------------------------------------------- /chapter6/Validation.html: -------------------------------------------------------------------------------- 1 | 2 | 25 | -------------------------------------------------------------------------------- /chapter9/Class.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 25 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/features/movies/movieApi.ts: -------------------------------------------------------------------------------- 1 | import {API_URL} from "../../setting/API"; 2 | /*import {Movie} from "./movieSlice";*/ 3 | import axios from "../../setting/our_axios"; 4 | import {Movie} from "./movieSlice"; 5 | 6 | 7 | const API = API_URL+"/movies" 8 | 9 | export function apiGetAllMovie(){ 10 | console.log('Called getAllMovie with axios'); 11 | return axios.get(API); 12 | } 13 | export function apiSaveMovie(movie:Movie) 14 | { 15 | return axios.post(API,movie); 16 | } 17 | export function apiUpdateMovie(movie:Movie) 18 | { 19 | return axios.put(API+'/'+movie._id,movie); 20 | } 21 | export function apiDeleteMovie(movie:Movie) 22 | { 23 | return axios.delete(API+'/'+movie._id); 24 | } -------------------------------------------------------------------------------- /backend/swagger.json: -------------------------------------------------------------------------------- 1 | { 2 | "definition": { 3 | "openapi": "2.0", 4 | "info": { 5 | "title": "LogRocket Express API with Swagger", 6 | "version": "0.1.0", 7 | "description": 8 | "This is a simple CRUD API application made with Express and documented with Swagger", 9 | "license": { 10 | "name": "MIT", 11 | "url": "https://spdx.org/licenses/MIT.html" 12 | }, 13 | "contact": { 14 | "name": "LogRocket", 15 | "url": "https://logrocket.com", 16 | "email": "info@email.com" 17 | } 18 | }, 19 | "servers": [ 20 | { 21 | "url": "http://localhost:3000/users" 22 | } 23 | ] 24 | }, 25 | "apis": ["./routes/users.js"] 26 | } -------------------------------------------------------------------------------- /chapter15/Animation.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |
8 | Original 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter3/NullUndefined.html: -------------------------------------------------------------------------------- 1 | 2 | 25 | -------------------------------------------------------------------------------- /chapter13/Promise.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | -------------------------------------------------------------------------------- /chapter14/Prototype.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 27 | -------------------------------------------------------------------------------- /chapter5/IfStatement.html: -------------------------------------------------------------------------------- 1 | 2 | 32 | -------------------------------------------------------------------------------- /chapter7/Filter.html: -------------------------------------------------------------------------------- 1 | 2 | 22 | -------------------------------------------------------------------------------- /chapter8/Value.html: -------------------------------------------------------------------------------- 1 | 2 | 32 | -------------------------------------------------------------------------------- /react-frontend/src/components/error-boundary/BuggyComponent.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | export default class BuggyComponent extends React.Component 3 | { 4 | constructor(props) { 5 | super(props); 6 | this.state = { counter: 0 }; 7 | this.handleClick = this.handleClick.bind(this); 8 | } 9 | 10 | handleClick() { 11 | this.setState(({counter}) => ({ 12 | counter: counter + 1 13 | })); 14 | } 15 | 16 | render() { 17 | let obj = {}; 18 | if (this.state.counter === 5) { 19 | // Simulate a JS error 20 | throw new Error('I crashed!'); 21 | } 22 | return

{this.state.counter}

; 23 | } 24 | } -------------------------------------------------------------------------------- /fp/Monad.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20 | -------------------------------------------------------------------------------- /chapter3/Mutable.html: -------------------------------------------------------------------------------- 1 | 2 | 34 | -------------------------------------------------------------------------------- /chapter6/ExtendLiteral.html: -------------------------------------------------------------------------------- 1 | 2 | 29 | -------------------------------------------------------------------------------- /chapter6/Seralization.html: -------------------------------------------------------------------------------- 1 | 2 | 25 | -------------------------------------------------------------------------------- /chapter8/CallApply.html: -------------------------------------------------------------------------------- 1 | 2 | 27 | -------------------------------------------------------------------------------- /react-frontend/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | /*background-color: #282c34;*/ 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | /*color: white;*/ 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /react-frontend/src/components/function_component/hook/UseIdDemo.js: -------------------------------------------------------------------------------- 1 | import React, {useId, useState,useCallback,useInsertionEffect} from 'react'; 2 | 3 | export default function UseIdDemo(props) 4 | { 5 | useInsertionEffect(()=>{ 6 | console.log('Run before DOM mutation'); 7 | }); 8 | console.log('Render'); 9 | const id = useId(); 10 | return ( 11 | <> 12 |
13 | 14 | 15 |
16 |
17 | 18 | 19 |
20 | 21 | ); 22 | } -------------------------------------------------------------------------------- /react-frontend/src/components/jsx/DynamicComponent.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function Admin() 4 | { 5 | return (
6 | Admin 7 |
); 8 | } 9 | function User() 10 | { 11 | return (
12 | User 13 |
); 14 | } 15 | let components = { 16 | 'Admin': Admin, 17 | 'User': User 18 | }; 19 | export default class DynamicComponent extends React.Component 20 | { 21 | constructor(props) { 22 | super(props); 23 | 24 | } 25 | 26 | render() { 27 | let Component = components[this.props.userType]; 28 | let data = "

Hello

"; 29 | return ( 30 |
31 | 32 | {data} 33 |
34 | ); 35 | } 36 | } -------------------------------------------------------------------------------- /chapter11/JsonParse.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 30 | -------------------------------------------------------------------------------- /chapter9/Generator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 31 | -------------------------------------------------------------------------------- /react-frontend/src/components/hoc/logProps.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | function logProps(WrappedComponent) 4 | { 5 | //console.log('Here ',WrappedComponent); 6 | return class extends React.Component 7 | { 8 | componentDidUpdate(prevProps) { 9 | console.log('Current props: ', this.props); 10 | console.log('Previous props: ', prevProps); 11 | } 12 | render() { 13 | console.log('Log props called ',this.props); 14 | return(
15 | { 16 | this.props.loading ?
Loading
: 17 | 18 | } 19 |
) 20 | 21 | } 22 | } 23 | } 24 | export default logProps; -------------------------------------------------------------------------------- /chapter11/JSON.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 29 | -------------------------------------------------------------------------------- /chapter5/Conditional.html: -------------------------------------------------------------------------------- 1 | 2 | 33 | -------------------------------------------------------------------------------- /chapter6/Logger.html: -------------------------------------------------------------------------------- 1 | 2 | 28 | -------------------------------------------------------------------------------- /fp/GroupBy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 29 | -------------------------------------------------------------------------------- /react-frontend/src/components/thrid_party/DatePicker.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import $ from 'jquery'; 3 | import datepickerFactory from 'jquery-datepicker'; 4 | import datepickerJAFactory from 'jquery-datepicker/i18n/jquery.ui.datepicker-ja'; 5 | datepickerFactory($); 6 | datepickerJAFactory($); 7 | 8 | export default class DatePicker extends React.Component 9 | { 10 | componentDidMount() { 11 | this.$el = $(this.el); 12 | this.$el.datepicker(); 13 | } 14 | 15 | componentWillUnmount() { 16 | this.$el.datepicker('destroy'); 17 | } 18 | render() { 19 | return (
20 | Date Picker 21 | this.el = el}> 23 |
); 24 | } 25 | } -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-float infinite 3s ease-in-out; 13 | } 14 | } 15 | 16 | .App-header { 17 | min-height: 100vh; 18 | display: flex; 19 | flex-direction: column; 20 | align-items: center; 21 | justify-content: center; 22 | font-size: calc(10px + 2vmin); 23 | } 24 | 25 | .App-link { 26 | color: rgb(112, 76, 182); 27 | } 28 | 29 | @keyframes App-logo-float { 30 | 0% { 31 | transform: translateY(0); 32 | } 33 | 50% { 34 | transform: translateY(10px); 35 | } 36 | 100% { 37 | transform: translateY(0px); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /redux-typescript-fourth-batch/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-float infinite 3s ease-in-out; 13 | } 14 | } 15 | 16 | .App-header { 17 | min-height: 100vh; 18 | display: flex; 19 | flex-direction: column; 20 | align-items: center; 21 | justify-content: center; 22 | font-size: calc(10px + 2vmin); 23 | } 24 | 25 | .App-link { 26 | color: rgb(112, 76, 182); 27 | } 28 | 29 | @keyframes App-logo-float { 30 | 0% { 31 | transform: translateY(0); 32 | } 33 | 50% { 34 | transform: translateY(10px); 35 | } 36 | 100% { 37 | transform: translateY(0px); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /react-redux-fourth-batch/src/setting/our_axios.js: -------------------------------------------------------------------------------- 1 | import {API_URL} from "./API"; 2 | const axios = require('axios'); 3 | 4 | axios.defaults.headers.post['Content-Type'] = 'application/json'; 5 | let store; 6 | 7 | export const injectStore = (_store) => { 8 | store = _store; 9 | } 10 | 11 | axios.interceptors.request.use(async function (config) { 12 | console.log('API request ',store.getState()); 13 | const authUser = store.getState().auth; 14 | console.log('API request auth user ',authUser); 15 | if( authUser.token) 16 | { 17 | config.headers.Authorization = 'Bearer '+ authUser.token; 18 | } 19 | 20 | return config; 21 | },function(error){ 22 | console.log("Axios interceptor error ",error); 23 | return error; 24 | }); 25 | 26 | export default axios; 27 | -------------------------------------------------------------------------------- /chapter15/ElementContent.html: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |
10 | Original 11 |
12 |
Another
13 | 14 | 15 | 16 | 17 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /chapter5/Finally.html: -------------------------------------------------------------------------------- 1 | 2 | 29 | -------------------------------------------------------------------------------- /chapter4/Assignment.html: -------------------------------------------------------------------------------- 1 | 2 | 33 | -------------------------------------------------------------------------------- /chapter6/Encapsulation.html: -------------------------------------------------------------------------------- 1 | 2 | 31 | -------------------------------------------------------------------------------- /react-frontend/src/components/render-property/MouseTracker.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | export default class MouseTracker extends React.Component { 3 | constructor(props) { 4 | super(props); 5 | this.handleMouseMove = this.handleMouseMove.bind(this); 6 | this.state = { x: 0, y: 0 }; 7 | } 8 | 9 | handleMouseMove(event) { 10 | this.setState({ 11 | x: event.clientX, 12 | y: event.clientY 13 | }); 14 | } 15 | 16 | render() { 17 | return ( 18 |
19 |

Move the mouse around!

20 |

The current mouse position is ({this.state.x}, {this.state.y})

21 |
22 | ); 23 | } 24 | } -------------------------------------------------------------------------------- /chapter6/Object.html: -------------------------------------------------------------------------------- 1 | 2 | 27 | --------------------------------------------------------------------------------